Strange enum type conversion
Andrew Haley
aph@redhat.com
Thu Dec 3 13:36:00 GMT 2009
John (Eljay) Love-Jensen wrote:
> Hi GCC developers,
>
> Andrew> Isn't [(1 << 31)] UB on a 32-bit machine as well? Looks like
> integer overflow to me.
>
> Challenge for the GCC developers:
>
> I would love if there was a switch like this: -fundefined-behavior-segv
>
> Such that if the source touches upon undefined behavior, it does:
> 1) compiler error
> 2) runtime SEGV
>
> Preferably the first, but in some unavoidable cases the second.
>
> Also, as far as I am concerned, with that switch enable, it would be
> plenty-fine-okay if the code had to be heavily instrumented (hence possibly
> huge* performance penalty) to check ranges and such so that at runtime the
> undefined behavior code incurs a SEGV.
>
> Furthermore, a -fimplementation-defined-behavior-segv would likewise be
> nice.
>
> I know... GCC is open source. Go ahead, add it myself, and submit the
> patch. :-)
It could be done in some cases, but in others would be very hard.
Andrew.
More information about the Gcc-help
mailing list