public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/30332] New: bit-field: optimization BUG?
@ 2006-12-30 8:21 s__nakayama at infoseek dot jp
2006-12-30 8:28 ` [Bug c++/30332] " pinskia at gcc dot gnu dot org
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: s__nakayama at infoseek dot jp @ 2006-12-30 8:21 UTC (permalink / raw)
To: gcc-bugs
The output is different by the optimization.
testcase:
#include <stdio.h>
struct S
{
unsigned int long long a:33;
};
int main ()
{
struct S x = { -1 };
typeof(+x.a) z = x.a+10;
printf("%llx\n", z);
return 0;
}
result:
$ g++ bug.cpp; ./a
200000009
$ g++ -O bug.cpp; ./a
9
gcc version: 4.2 20061212
--
Summary: bit-field: optimization BUG?
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: s__nakayama at infoseek dot jp
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30332
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/30332] bit-field: optimization BUG?
2006-12-30 8:21 [Bug c++/30332] New: bit-field: optimization BUG? s__nakayama at infoseek dot jp
@ 2006-12-30 8:28 ` pinskia at gcc dot gnu dot org
2007-01-21 5:29 ` bangerth at dealii dot org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-12-30 8:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2006-12-30 08:28 -------
So we do x.a+10 in unsigned long long and then cast it to the bit-field type.
I am thinking we are getting the wrong type for the typeof anyways.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30332
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/30332] bit-field: optimization BUG?
2006-12-30 8:21 [Bug c++/30332] New: bit-field: optimization BUG? s__nakayama at infoseek dot jp
2006-12-30 8:28 ` [Bug c++/30332] " pinskia at gcc dot gnu dot org
@ 2007-01-21 5:29 ` bangerth at dealii dot org
2007-01-21 5:32 ` [Bug c++/30332] [4.1/4.2?/4.3? regression] " bangerth at dealii dot org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: bangerth at dealii dot org @ 2007-01-21 5:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from bangerth at dealii dot org 2007-01-21 05:29 -------
No, that's not the case. We can print the types:
-------------
#include <stdio.h>
#include <iostream>
#include <typeinfo>
struct S
{
unsigned int long long a:33;
};
int main ()
{
struct S x = { -1 };
typeof(+x.a) z = x.a+10;
printf("%llx\n", z);
std::cout << typeid(x.a).name() << ' ' << typeid(z).name()
<< std::endl;
return 0;
}
--------------
g/x> ./a.out
200000009
y y
g/x> c++ x.cc -O2
g/x> ./a.out
9
y y
'y' apparently encodes unsigned long long.
W.
--
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |bangerth at dealii dot org
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2007-01-21 05:29:10
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30332
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/30332] [4.1/4.2?/4.3? regression] bit-field: optimization BUG?
2006-12-30 8:21 [Bug c++/30332] New: bit-field: optimization BUG? s__nakayama at infoseek dot jp
2006-12-30 8:28 ` [Bug c++/30332] " pinskia at gcc dot gnu dot org
2007-01-21 5:29 ` bangerth at dealii dot org
@ 2007-01-21 5:32 ` bangerth at dealii dot org
2007-01-21 22:01 ` [Bug c++/30332] [4.1/4.2/4.3 " pinskia at gcc dot gnu dot org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: bangerth at dealii dot org @ 2007-01-21 5:32 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from bangerth at dealii dot org 2007-01-21 05:32 -------
In any case, I consider this a bug in gcc. The problem doesn't happen with
gcc 3.3 or 3.4 or 4.0, so it's a regression.
That said, there's a second problem: before 4.1.x, we warned:
g/x> /home/bangerth/bin/gcc-4.0.x/bin/c++ x.cc -O2
x.cc: In function 'int main()':
x.cc:13: warning: converting negative value '-0x000000001' to 'long long
unsigned int'
This doesn't happen any more, not even with -W -Wall
W.
--
bangerth at dealii dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Known to fail| |4.1.0
Known to work| |3.3.6 3.4.6 4.0.1
Summary|bit-field: optimization BUG?|[4.1/4.2?/4.3? regression]
| |bit-field: optimization BUG?
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30332
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/30332] [4.1/4.2/4.3 regression] bit-field: optimization BUG?
2006-12-30 8:21 [Bug c++/30332] New: bit-field: optimization BUG? s__nakayama at infoseek dot jp
` (2 preceding siblings ...)
2007-01-21 5:32 ` [Bug c++/30332] [4.1/4.2?/4.3? regression] " bangerth at dealii dot org
@ 2007-01-21 22:01 ` pinskia at gcc dot gnu dot org
2007-01-25 6:06 ` mmitchel at gcc dot gnu dot org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2007-01-21 22:01 UTC (permalink / raw)
To: gcc-bugs
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |4.1.2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30332
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/30332] [4.1/4.2/4.3 regression] bit-field: optimization BUG?
2006-12-30 8:21 [Bug c++/30332] New: bit-field: optimization BUG? s__nakayama at infoseek dot jp
` (3 preceding siblings ...)
2007-01-21 22:01 ` [Bug c++/30332] [4.1/4.2/4.3 " pinskia at gcc dot gnu dot org
@ 2007-01-25 6:06 ` mmitchel at gcc dot gnu dot org
2007-02-14 9:28 ` mmitchel at gcc dot gnu dot org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-01-25 6:06 UTC (permalink / raw)
To: gcc-bugs
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30332
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/30332] [4.1/4.2/4.3 regression] bit-field: optimization BUG?
2006-12-30 8:21 [Bug c++/30332] New: bit-field: optimization BUG? s__nakayama at infoseek dot jp
` (4 preceding siblings ...)
2007-01-25 6:06 ` mmitchel at gcc dot gnu dot org
@ 2007-02-14 9:28 ` mmitchel at gcc dot gnu dot org
2007-02-21 15:12 ` rguenth at gcc dot gnu dot org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2007-02-14 9:28 UTC (permalink / raw)
To: gcc-bugs
--
mmitchel at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|4.1.2 |4.1.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30332
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/30332] [4.1/4.2/4.3 regression] bit-field: optimization BUG?
2006-12-30 8:21 [Bug c++/30332] New: bit-field: optimization BUG? s__nakayama at infoseek dot jp
` (5 preceding siblings ...)
2007-02-14 9:28 ` mmitchel at gcc dot gnu dot org
@ 2007-02-21 15:12 ` rguenth at gcc dot gnu dot org
2007-12-11 13:47 ` rguenth at gcc dot gnu dot org
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-02-21 15:12 UTC (permalink / raw)
To: gcc-bugs
------- 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
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/30332] [4.1/4.2/4.3 regression] bit-field: optimization BUG?
2006-12-30 8:21 [Bug c++/30332] New: bit-field: optimization BUG? s__nakayama at infoseek dot jp
` (6 preceding siblings ...)
2007-02-21 15:12 ` rguenth at gcc dot gnu dot org
@ 2007-12-11 13:47 ` rguenth at gcc dot gnu dot org
2008-01-25 12:56 ` [Bug c++/30332] [4.1/4.2 " rguenth at gcc dot gnu dot org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-12-11 13:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from rguenth at gcc dot gnu dot org 2007-12-11 13:47 -------
Related to PR33887.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
BugsThisDependsOn| |33887
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30332
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/30332] [4.1/4.2 regression] bit-field: optimization BUG?
2006-12-30 8:21 [Bug c++/30332] New: bit-field: optimization BUG? s__nakayama at infoseek dot jp
` (7 preceding siblings ...)
2007-12-11 13:47 ` rguenth at gcc dot gnu dot org
@ 2008-01-25 12:56 ` rguenth at gcc dot gnu dot org
2008-07-04 21:48 ` [Bug c++/30332] [4.2 " jsm28 at gcc dot gnu dot org
2009-03-30 20:20 ` jsm28 at gcc dot gnu dot org
10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2008-01-25 12:56 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from rguenth at gcc dot gnu dot org 2008-01-25 12:14 -------
Fixed on the trunk by the fix for PR33887.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Known to work|3.3.6 3.4.6 4.0.1 |3.3.6 3.4.6 4.0.1 4.3.0
Summary|[4.1/4.2/4.3 regression] |[4.1/4.2 regression] bit-
|bit-field: optimization BUG?|field: optimization BUG?
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30332
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/30332] [4.2 regression] bit-field: optimization BUG?
2006-12-30 8:21 [Bug c++/30332] New: bit-field: optimization BUG? s__nakayama at infoseek dot jp
` (8 preceding siblings ...)
2008-01-25 12:56 ` [Bug c++/30332] [4.1/4.2 " rguenth at gcc dot gnu dot org
@ 2008-07-04 21:48 ` jsm28 at gcc dot gnu dot org
2009-03-30 20:20 ` jsm28 at gcc dot gnu dot org
10 siblings, 0 replies; 12+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2008-07-04 21:48 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from jsm28 at gcc dot gnu dot org 2008-07-04 21:47 -------
Closing 4.1 branch.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[4.1/4.2 regression] bit- |[4.2 regression] bit-field:
|field: optimization BUG? |optimization BUG?
Target Milestone|4.1.3 |4.2.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30332
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug c++/30332] [4.2 regression] bit-field: optimization BUG?
2006-12-30 8:21 [Bug c++/30332] New: bit-field: optimization BUG? s__nakayama at infoseek dot jp
` (9 preceding siblings ...)
2008-07-04 21:48 ` [Bug c++/30332] [4.2 " jsm28 at gcc dot gnu dot org
@ 2009-03-30 20:20 ` jsm28 at gcc dot gnu dot org
10 siblings, 0 replies; 12+ messages in thread
From: jsm28 at gcc dot gnu dot org @ 2009-03-30 20:20 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from jsm28 at gcc dot gnu dot org 2009-03-30 20:20 -------
Closing 4.2 branch, fixed in 4.3.
--
jsm28 at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Known to fail|4.1.0 |4.1.0 4.2.5
Resolution| |FIXED
Target Milestone|4.2.5 |4.3.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30332
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2009-03-30 20:20 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-30 8:21 [Bug c++/30332] New: bit-field: optimization BUG? s__nakayama at infoseek dot jp
2006-12-30 8:28 ` [Bug c++/30332] " pinskia at gcc dot gnu dot org
2007-01-21 5:29 ` bangerth at dealii dot org
2007-01-21 5:32 ` [Bug c++/30332] [4.1/4.2?/4.3? regression] " bangerth at dealii dot org
2007-01-21 22:01 ` [Bug c++/30332] [4.1/4.2/4.3 " pinskia at gcc dot gnu dot org
2007-01-25 6:06 ` mmitchel at gcc dot gnu dot org
2007-02-14 9:28 ` mmitchel at gcc dot gnu dot org
2007-02-21 15:12 ` rguenth at gcc dot gnu dot org
2007-12-11 13:47 ` rguenth at gcc dot gnu dot org
2008-01-25 12:56 ` [Bug c++/30332] [4.1/4.2 " rguenth at gcc dot gnu dot org
2008-07-04 21:48 ` [Bug c++/30332] [4.2 " jsm28 at gcc dot gnu dot org
2009-03-30 20:20 ` jsm28 at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).