Jump to content
  • Advertisement
Sign in to follow this  
carl404

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.

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!