This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: float to int conversion


On Mon, 22 Apr 2013 11:44:58 +0000
"Warlich, Christof" <christof.warlich@siemens.com> wrote:

> But imho, anything, even "undefined (but fixed)", would be better than
> "varying depending on the level of optimization". 
"undefined" behavior can't be "fixed". if it is fixed, it is defined.
the only way one can get "fixed" behavior is to change the standard, so
that standard will clearly specify what to do in such cases. until than
compiler authors are free to change results of undefined operations.

it's really a bad practice to depend on undefined behavior. this will
tie the software to the given version of the given compiler and
architecture. even recompiling the software with the exact same
compiler version, but for ARM instead of x86, for example, can break
everything. so in practice one should assume that result of "undefined
behavior" can be *anything*, including creating new Black Hole or Sun
becomes Supernova.

Attachment: signature.asc
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]