Ian Lance Taylor <iant@xxxxxxxxxx> writes: > Francis Moreau <francis.moro@xxxxxxxxx> writes: > >> I mean that I find quite dangerous that a program can subtly break (or >> behave differently) depending on the optimisation level. > > I think it's important to say clearly that only an invalid program can > subtly behave differently. A valid program will work correctly at all > optimization levels. I agree. > > >> For example a user can rely on aliasing undefined behaviour (one reason >> is that is simply not aware of this fact), compile its program with no >> optimisation level, do some testings and find no problem so far. Then >> increase the level of optimisation and then the program start to behave >> incorrectly. I guess he's going to spend some time before discovering >> what's going on. >> >> Specially since no warnings can pop up with -O2 for example. > > It is unfortunately very difficult to issue correct warnings for these > cases. That's why -Wstrict-aliasing is optional: it produces both false > positives and false negatives. I can understand your point. >> An exhaustive list would be better I think. > > I don't know how to write an exhaustive list except in terms of > optimizations that are not performed. Again I can understand and your other post (Message-ID: mcr1v6v68fh.fsf@xxxxxxxxxx) makes thing clearer. Thanks -- Francis