News for hackers. Stuff that matters.
Re:Deep C by pwaring on Monday October 10, 2011 @11:24AM (#3094147)
I'm a bit surprised by the suggestion that optimisation somehow makes the compiler work harder (e.g. catching uninitialised variables), isn't that what -W flags are for? I'm not sure that optimiser flags will catch anything with gcc that -Wall and -Wextra would miss.
Re:Deep C by silentbicycle on Monday October 10, 2011 @12:32PM (#3094504)
There are warning flags that aren't even usable unless you're compiling with optimization on, such as -Wuninitialized.

As the gcc man page says, "These warnings are possible only in optimizing compilation, because they require data flow information that is computed only when optimizing." (emphasis mine)

Re:Deep C by pwaring on Monday October 10, 2011 @02:43PM (#3095173)
That only applies to warnings in conjunction with optimisations though, just turning optimisations on (as shown in the example slide) won't necessarily pick up uninitialised variables. For example, if I compile the example given in the slides with -O, -O1, -O2 or -O3 with gcc, I don't get an error/warning, but I do if I use -Wall.

Also, you can use -Wuninitialized without optimisations and it picks up the problem, at least in my version of gcc (4.5.2).

Re:Deep C by greyfade on Monday October 10, 2011 @04:06PM (#3095559)
The example in the slide uses `-Wall -O`, and `-Wall` includes `-Wuninitialized`.

Recent versions of GCC have a revamped syntax tree analyzer, which was needed for the new tree-vectorize features. It does more work from the outset these days, so I'm not surprised if it throws the warning earlier.

Re:Deep C by silentbicycle on Monday October 10, 2011 @04:08PM (#3095566)
Indeed, you need the warning and the optimization to make it work.

That note came from the man page for i686-apple-darwin11-llvm-gcc-4.2, FWIW.

Re:Deep C by pwaring on Tuesday October 11, 2011 @07:00AM (#3098075)
Ah, I'm using a newer version of gcc, which seems to catch the warning regardless of the optimisation level (including none at all). The text of the man page also seems to be different.
Re:Deep C by froydnj on Monday October 10, 2011 @12:17PM (#3094420)
-Wuninitialized in gcc depends on the optimization settings: http://gcc.gnu.org/onlinedocs/gcc-4.6.1/gcc/Warning-Options....