[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Having fun with the following C code (UB)



On 10/04/14 20:59, Ian Jackson wrote:
Vincent Lefevre writes ("Re: Having fun with the following C code (UB)"):
On 2014-04-10 11:48:44 +0000, Thorsten Glaser wrote:
And GCC is a repeat offender which actually does do that.
If you don't like that, you should use the -fwrapv option.
Sadly that doesn't deal with all of these malicious optimisations.

I never did understand what people expect. gcc uses the undefined behavior to not emit checks it would otherwise have to, so that your code runs faster. This affects not only those corner cases, where you are relying on this behaving a certain way, but especially in everyday code, where those undefined behavior allows GCC to save you lots of cycles.

Are you really sure you want to have slower code just so that your corner cases are easier for you? How is that a reasonable trade-off to make?

Shachar

Reply to: