GDC2 compilation warnings

Leandro Lucarella luca at llucax.com.ar
Wed Nov 24 05:46:54 PST 2010


Iain Buclaw, el 24 de noviembre a las 01:29 me escribiste:
> == Quote from bearophile (bearophileHUGS at lycos.com)'s article
> > While compiling GDC2 today I have seen hundreds of warnings, usually one of 5 types:
> 
> I'm rather thankful that you didn't try compiling a month or two ago then. :~)
> I've cut down the amount of warnings emitted by a *lot*, and I can't even begin to
> stress that fact.
> 
> > ../../gcc/d/d-gcc-real.h: In member function ?const real_value& real_t::rv() const?:
> > ../../gcc/d/d-gcc-real.h:54: warning: dereferencing type-punned pointer will
> break strict-aliasing rules
> 
> If you have a great idea to fix this warning, please send a patch.
[...]
> > In file included from ../../gcc/d/dmd2/root.h:29,
> >                  from ../../gcc/d/dmd2/total.h:24,
> >                  from ../../gcc/d/d-cppmngl.cc:25:
> > ../../gcc/d/dmd2/dchar.h:155: warning: unused parameter ?pstart?
> > Comments:
> > - Unused variable warning: this is useful to avoid bugs;
> > - Type-punned pointer warning: so far I have never received an answer to my
> questions about this possible problem in D.

These are important issues. This can heavily break the code when
compiling with optimizations (-O2, -O3, -Os). Basically, you can't
access an object with a type using a pointer to an incompatible type
(except through an union). If is too hard to fix, use
-fno-strict-aliasing when compiling with -O2, -O3 or -Os to inhibit that
optimization.

-- 
Leandro Lucarella (AKA luca)                     http://llucax.com.ar/
----------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145  104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------
Hey you, don't tell me there's no hope at all
Together we stand, divided we fall.


More information about the Digitalmars-d mailing list