Microsoft 1-0 GNU [entries|reading|network|archive]
simont

[ userinfo | dreamwidth userinfo ]
[ archive | journal archive ]

Fri 2008-05-09 10:13
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!)

LinkReply
[identity profile] ewx.livejournal.comFri 2008-05-09 09:31
"warning: empty body in an if-statement" doesn't seem like "without question" to me. gcc 4.1.2 with -W turned on.
Link Reply to this | Thread
[personal profile] simontFri 2008-05-09 09:35
Hm, so it does. Wonder why only VC++'s warning found its way out of the bowels of our build system, then.
Link Reply to this | Parent
[personal profile] simontFri 2008-05-09 09:38
Hmm, it doesn't seem to happen with just -Wall. And I can't remember exactly why, but ISTR not liking -W because it also enables some genuinely excessively draconian warnings.
Link Reply to this | Parent | Thread
[identity profile] ewx.livejournal.comFri 2008-05-09 09:45
There are -Wno-... for some of the things -W turns on.
Link Reply to this | Parent
[identity profile] woodpijn.livejournal.comFri 2008-05-09 09:52
I agree that long lines are bad, but doesn't your editor wrap them? Why not?
Link Reply to this | Thread
[personal profile] simontFri 2008-05-09 10:00
It is an annoying missing feature in my editor that it isn't able to go into a wrapping mode. Normally this doesn't bother me greatly (for most purposes I find it more useful to see a rectangular window on the idealised representation of the text file), but you have a point that in this particular case it would indeed be more useful.

(Migrating to another editor would involve rewriting over ten years' worth of accumulated editor tuning and configuration, so I have considerable inertia on the matter...)
Link Reply to this | Parent
[personal profile] gerald_duckFri 2008-05-09 10:13
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.
Link Reply to this | Thread
[identity profile] ewx.livejournal.comFri 2008-05-09 11:08
GCC doesn't find the shortest name but it does now seem to say things like int2int and std::string instead of map<int, int> or std::basic_string<endless guff about allocators>.
Link Reply to this | Parent | Thread
[identity profile] ewx.livejournal.comFri 2008-05-09 11:10
(...it doesn't say int2int::iterator though, preferring struct std::_Rb_tree_iterator<std::pair<const int, int> >. So there is work yet to be done, at least as of 4.1.2 l-(
Link Reply to this | Parent
[identity profile] lionsphil.livejournal.comFri 2008-05-09 23:39
Maybe one day (http://en.wikipedia.org/wiki/C%2B%2B0x#Concepts) at least using the STL won't mean "please spam me rotten with unnecessary template details".
Link Reply to this | Parent
navigation
[ go | Previous Entry | Next Entry ]
[ add | to Memories ]