This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/30332] [4.1/4.2/4.3 regression] bit-field: optimization BUG?
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 21 Feb 2007 15:12:08 -0000
- Subject: [Bug c++/30332] [4.1/4.2/4.3 regression] bit-field: optimization BUG?
- References: <bug-30332-10812@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #4 from rguenth at gcc dot gnu dot org 2007-02-21 15:12 -------
With 4.1.3 for C we have, even without optimizing
> ./xgcc -B. -o t t.c -Wall
t.c: In function 'main':
t.c:13: warning: format '%llx' expects type 'long long unsigned int', but
argument 2 has type 'long unsigned int:33'
> ./t
9
For C++ we for all optimizations get
> ./t
200000009
The difference after gimplification is
main ()
{
<unnamed type> D.2220;
int D.2221;
struct S x;
<unnamed type> z;
x.a = 8589934591;
D.2220 = x.a;
z = D.2220 + 10;
printf (&"%llx\n"[0], z);
D.2221 = 0;
return D.2221;
}
vs.
int main() ()
{
long long unsigned int D.2823;
int D.2824;
{
struct S x;
long long unsigned int z;
x.a = 8589934591;
D.2823 = x.a;
z = D.2823 + 10;
printf (&"%llx\n"[0], z);
D.2824 = 0;
return D.2824;
}
D.2824 = 0;
return D.2824;
}
i.e. typeof(+x.a) yields a different result for C and C++. For C we leave
bitfield types bigger than int alone and don't promote them.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30332