public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/21756] New: inconsistent result of left shift
@ 2005-05-25 19:33 wb at fnal dot gov
2005-05-25 19:52 ` [Bug c++/21756] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: wb at fnal dot gov @ 2005-05-25 19:33 UTC (permalink / raw)
To: gcc-bugs
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/21756] inconsistent result of left shift
2005-05-25 19:33 [Bug c++/21756] New: inconsistent result of left shift wb at fnal dot gov
@ 2005-05-25 19:52 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-25 19:52 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-05-25 19:34 -------
This is undefined as per 5.8/1:
"The behavior is undefined if the right operand is negative, or greater than or equal to the length in
bigs of the promoted left operand".
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21756
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-05-25 19:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-25 19:33 [Bug c++/21756] New: inconsistent result of left shift wb at fnal dot gov
2005-05-25 19:52 ` [Bug c++/21756] " pinskia 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).