public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "sbgccbug at yahoo dot co.uk" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/53745] New: Bitshifted value (1 << 31) within enumerator class is calculated incorrectly during compilation. Date: Thu, 21 Jun 2012 13:04:00 -0000 [thread overview] Message-ID: <bug-53745-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53745 Bug #: 53745 Summary: Bitshifted value (1 << 31) within enumerator class is calculated incorrectly during compilation. Classification: Unclassified Product: gcc Version: 4.6.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned@gcc.gnu.org ReportedBy: sbgccbug@yahoo.co.uk When compiling an 'enum class' (-std=c++0x) that uses bit-shifted values, the result of "1 << 31" is calculated incorrectly, resulting in -0x80000000 (*negative* 2^31) rather than the correct result of 0x80000000: // *** BEGIN EXAMPLE CODE (main.cpp) *** enum class EnumTest : unsigned long int { A = 1 << 30, B = 1 << 31 }; int main() { return 0; } // *** END EXAMPLE CODE *** // *** BEGIN gcc-4.6.1 OUTPUT *** main.cpp|4|error: enumerator value -0x00000000080000000 is too large for underlying type ‘long unsigned int’| // *** END gcc-4.6.1 OUTPUT ***
next reply other threads:[~2012-06-21 13:04 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-06-21 13:04 sbgccbug at yahoo dot co.uk [this message] 2012-06-21 13:35 ` [Bug c++/53745] " schwab@linux-m68k.org 2012-06-21 13:36 ` redi at gcc dot gnu.org 2012-06-21 17:52 ` [Bug c++/53745] [C++11] Poor diagnostic for ill-formed narrowing conversion in enumerator initializer redi at gcc dot gnu.org 2013-05-03 23:23 ` paolo.carlini at oracle dot com 2013-05-04 13:09 ` paolo.carlini at oracle dot com 2013-05-05 0:29 ` paolo.carlini at oracle dot com
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-53745-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).