public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/51147] New: attribute((mode(byte))) on an enum generates wrong code
@ 2011-11-15 22:50 pkoning at gcc dot gnu.org
2011-11-15 23:06 ` [Bug c/51147] " pkoning at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: pkoning at gcc dot gnu.org @ 2011-11-15 22:50 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51147
Bug #: 51147
Summary: attribute((mode(byte))) on an enum generates wrong
code
Classification: Unclassified
Product: gcc
Version: 4.5.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: pkoning@gcc.gnu.org
Created attachment 25830
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25830
Test case file
In an attempt to work around bug 49459, I tried putting attribute(mode_byte))
on the enum declaration (instead of on the typedef as in that bug).
While that fixes the wrong debug output, it instead gives me seriously invalid
code. The attached testcase shows the issue. The compiler appears to handle
the functions foo and bar as if they return 1 unconditionally, so foo is
called, bar is not, and test returns 1 unconditionally.
Looking at the tree dump files, I see in the 001t.tu file something odd about
the return type of foo() -- it is showing up as an enum (unsigned) whose min
value is 0 and max value is -1. I'm not sure how that causes the specific
failure but it makes me wonder. The mishandling of the function return values
shows up right away (in the 003t.original dump file).
The bug has been seen in 4.5.1 and 4.6.1. I also tried 3.3.3 because I happen
to have it handy, but there the compiler crashes).
A 4.1.2 compiler (stock gcc on my Linux) gets it wrong also, with the addition
that it warns "Comparison is always true due to limited range of data type".
4.5.1 does not say so (not even with -Wall).
All this is with -O2.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/51147] attribute((mode(byte))) on an enum generates wrong code
2011-11-15 22:50 [Bug c/51147] New: attribute((mode(byte))) on an enum generates wrong code pkoning at gcc dot gnu.org
@ 2011-11-15 23:06 ` pkoning at gcc dot gnu.org
2011-11-15 23:07 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pkoning at gcc dot gnu.org @ 2011-11-15 23:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51147
Paul Koning <pkoning at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
Known to fail| |4.1.2, 4.5.1, 4.6.1
Severity|normal |major
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/51147] attribute((mode(byte))) on an enum generates wrong code
2011-11-15 22:50 [Bug c/51147] New: attribute((mode(byte))) on an enum generates wrong code pkoning at gcc dot gnu.org
2011-11-15 23:06 ` [Bug c/51147] " pkoning at gcc dot gnu.org
@ 2011-11-15 23:07 ` pinskia at gcc dot gnu.org
2011-11-15 23:28 ` pinskia at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-11-15 23:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51147
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|major |normal
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/51147] attribute((mode(byte))) on an enum generates wrong code
2011-11-15 22:50 [Bug c/51147] New: attribute((mode(byte))) on an enum generates wrong code pkoning at gcc dot gnu.org
2011-11-15 23:06 ` [Bug c/51147] " pkoning at gcc dot gnu.org
2011-11-15 23:07 ` pinskia at gcc dot gnu.org
@ 2011-11-15 23:28 ` pinskia at gcc dot gnu.org
2011-11-16 3:44 ` pkoning at gcc dot gnu.org
2011-11-18 13:12 ` pkoning at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2011-11-15 23:28 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51147
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2011-11-15 23:06:26 UTC ---
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15224 fixed the ICE ..
Note using attribute packed is more likely what you want to do rather than
using mode.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/51147] attribute((mode(byte))) on an enum generates wrong code
2011-11-15 22:50 [Bug c/51147] New: attribute((mode(byte))) on an enum generates wrong code pkoning at gcc dot gnu.org
` (2 preceding siblings ...)
2011-11-15 23:28 ` pinskia at gcc dot gnu.org
@ 2011-11-16 3:44 ` pkoning at gcc dot gnu.org
2011-11-18 13:12 ` pkoning at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pkoning at gcc dot gnu.org @ 2011-11-16 3:44 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51147
--- Comment #2 from Paul Koning <pkoning at gcc dot gnu.org> 2011-11-16 01:47:27 UTC ---
Thanks, I'll give that a try for another workaround.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/51147] attribute((mode(byte))) on an enum generates wrong code
2011-11-15 22:50 [Bug c/51147] New: attribute((mode(byte))) on an enum generates wrong code pkoning at gcc dot gnu.org
` (3 preceding siblings ...)
2011-11-16 3:44 ` pkoning at gcc dot gnu.org
@ 2011-11-18 13:12 ` pkoning at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: pkoning at gcc dot gnu.org @ 2011-11-18 13:12 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51147
--- Comment #3 from Paul Koning <pkoning at gcc dot gnu.org> 2011-11-18 11:49:56 UTC ---
That workaround seems to do the right thing for what I need, so I'm no longer
stuck. Thanks for the suggestion.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-11-18 11:51 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-15 22:50 [Bug c/51147] New: attribute((mode(byte))) on an enum generates wrong code pkoning at gcc dot gnu.org
2011-11-15 23:06 ` [Bug c/51147] " pkoning at gcc dot gnu.org
2011-11-15 23:07 ` pinskia at gcc dot gnu.org
2011-11-15 23:28 ` pinskia at gcc dot gnu.org
2011-11-16 3:44 ` pkoning at gcc dot gnu.org
2011-11-18 13:12 ` pkoning at gcc dot gnu.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).