Date: Sat, 15 Jan 2011 14:36:50 +1100 From: matthew green <m...@eterna.com.au> Message-ID: <399.1295062...@splode.eterna.com.au>
| > You also need to debug code with the same compilation options as you | > will use for any final builds - otherwise you can get some very | > nasty surprises. | i generally concur with this, though others don't :-) It all depends what you're doing - for more or less mature code, I agree. For new code in development, where you're not really worrying about obscure corner cases yet, but simply whether the code as written is anything like logically sane, it is a lot easier to debug if the compiler implements exactly what you wrote, so you can step through it and observe what happens (and have your lunacy revealed in starkly obvious ways). When the compiler starts optimising things, it becomes way too tempting to blame the compiler when the end result isn't what was intended - I wrote xxxxx, but the compiler produced something different, it must be broken. The original poster indicated this was new code in development, in that environment, -O0 might be a very useful way to help get the code close to correct, before setting the compiler optimiser loose on it. On the other hand, I certainly don't agree with the "code fails with -O2, and works with -O0, so compiler must be broken, and to compensate just use -O0 for this file" attitude that is sometimes seen - or not without a lot of analysis and demonstration that the compiler really is broken. kre