This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/21756] New: inconsistent result of left shift
- From: "wb at fnal dot gov" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 25 May 2005 19:26:39 -0000
- Subject: [Bug c++/21756] New: inconsistent result of left shift
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Reading specs from /usr/local/lib/gcc/i686-pc-cygwin/3.4.4/specs
Configured with: ../configure --enable-languages=c,c++
Thread model: single
gcc version 3.4.4
// -------------------------
// evaluate 1 << 32 in two different ways,
// obtaining different results
#include <iostream>
int main()
{
unsigned long k = 32UL;
unsigned long r1 = ( 1UL << k ); // incorrectly evaluated per 5.8/2
std::cout << "r1 = " << r1 << "\n"; // emits "r1 = 1"
unsigned long r2 = ( 1UL << 32UL ); // warns, but correctly evaluated
std::cout << "r2 = " << r2 << "\n"; // emits "r2 = 0"
return 0;
}
--
Summary: inconsistent result of left shift
Product: gcc
Version: 3.4.4
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: wb at fnal dot gov
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21756