Re: Possible bug in gcc 4.4.7

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

 



On 09/17/2014 06:15 PM, Andy Falanga (afalanga) wrote:

> Ha, nothing except my thinking that, because I was casting a
> reference, I had to use reinterpret_cast<>.  Of course, that (your
> suggestion) worked for me.  Please point me to the correct section
> of the language spec so that I might better understand why this is
> undefined behavior.

Here's the C version:

"6.5 Expressions":

An object shall have its stored value accessed only by an lvalue
expression that has one of the following types:

    a type compatible with the effective type of the object,

    a qualified version of a type compatible with the effective type
    of the object,

    a type that is the signed or unsigned type corresponding to the
    effective type of the object,

    a type that is the signed or unsigned type corresponding to a
    qualified version of the effective type of the object,

    an aggregate or union type that includes one of the aforementioned
    types among its members (including, recursively, a member of a
    subaggregate or contained union), or

    a character type.

C++ uses the same rule.  If you access an object using an lvalue
expression of an incompatible type, all bets are off.

static_cast<Flag>(reinterpret_cast<unsigned int&>(f1) is an example
of such an expression.

Andrew.





[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux