simont: A picture of me in 2016 (Default)
simont ([personal profile] simont) wrote2008-05-09 10:13 am

Microsoft 1-0 GNU

I've just discovered that if you write the following code:

    if (condition);
{
statement;
}

then gcc will accept it without question, whereas Visual C++ will give a warning pointing out that the semicolon after the closing parenthesis was probably not what you actually wanted to do. One point to Visual C++; none to gcc. Unusual, since gcc normally seems better at this kind of ‘probably not what you meant’ warning.

(I wouldn't have made the error at all if it hadn't been for this wretched code I'm maintaining which was written by someone who didn't think there was anything wrong with five-mile-long individual source lines. I can't reliably check there isn't rubbish at the ends of the lines if I can't reliably see the ends of the lines!)

ext_8103: (Default)

[identity profile] ewx.livejournal.com 2008-05-09 09:31 am (UTC)(link)
"warning: empty body in an if-statement" doesn't seem like "without question" to me. gcc 4.1.2 with -W turned on.

[identity profile] woodpijn.livejournal.com 2008-05-09 09:52 am (UTC)(link)
I agree that long lines are bad, but doesn't your editor wrap them? Why not?
gerald_duck: (duck and computer)

[personal profile] gerald_duck 2008-05-09 10:13 am (UTC)(link)
Personally, I'd pay good money (out of my own pocket) for a C++ compiler that gave types their shortest possible name in the prevailing scope when emitting errors.