This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/21756] New: inconsistent result of left shift


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]