# Compiler error ?

This topic is 4863 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello! By accident I wrote this line: char *test = (char *) new char[10,10]; Compiler (VC 6.0, GCC) was able to compile it, the result was allocation of 10 bytes. Why did it happend ? It should be discovered as parse error during compilation.

##### Share on other sites
Quote:
 It should be discovered as parse error during compilation.

No it shouldn't. C++ has a comma expression which allows you to do this. The value of the expression is, I think, the last in the list (otherwise the first).
10 == 1,2,3,4,5,6,7,8,9,10

This is a valid expression and is also true. In your example the cast is superfluous btw.

Its use is when some of the expressions's evaluations have side effects such as:
unsigned int s = 0;while( cin >> i, i > 0 )  s += i;

Illco

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 14
• 11
• 29
• 15
• 41
• ### Forum Statistics

• Total Topics
634838
• Total Posts
3019568
×