This is the mail archive of the gcc@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: SRA problem with uninitialzed fields


On Fri, 24 Sep 2004, Robert Dewar wrote:

> I am completely puzzled as to what reduced-width types have to do
> with this example at the C++ semantic level, or are you just making
> a comment about the internal implementation and why it happens to
> work for C++ and not for C (as far as I can see these programs have
> identical semantics in C and C++)

The internal representation in the front ends most cleanly follows the 
rules of the respective standards.  This then leads to different 
representations in GIMPLE, although the semantics in this case are the 
same for C and C++.  It would no doubt be desirable for the tree 
optimizers to be able to do the same optimizations in both cases, perhaps 
translating one representation into the other (both being valid GIMPLE).

The cases which have different semantics are such as

struct s { unsigned long a:40, b:40; } x;

unsigned long f() { return x.a + x.b; }

where in C, but not C++, the result of the addition is masked to 40 bits 
(presuming 32-bit int, 64-bit long for this example).

-- 
Joseph S. Myers               http://www.srcf.ucam.org/~jsm28/gcc/
  http://www.srcf.ucam.org/~jsm28/gcc/#c90status - status of C90 for GCC 4.0
    jsm@polyomino.org.uk (personal mail)
    jsm28@gcc.gnu.org (Bugzilla assignments and CCs)


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