public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/26516]  New: warning: left shift count >= width of type
@ 2006-03-01 18:57 mnmoran at bellsouth dot net
  2006-03-01 19:02 ` [Bug c/26516] " pinskia at gcc dot gnu dot org
  0 siblings, 1 reply; 2+ messages in thread
From: mnmoran at bellsouth dot net @ 2006-03-01 18:57 UTC (permalink / raw)
  To: gcc-bugs

Notice that I have tried this with several 32-bit native and
cross GCC compilers including versions 3.2.2, 3.3, and 4.0.2.

In the test-case that follows, I get the warning in spite of the
fact that the conditional is constant and "bitNumber" must always
be less than 8 to execute the conditional.

I discovered this feature while trying to write a generic C++
template where the "bitNumber" is a template parameter.

I expected the constant conditional statement to be optimized
with a "smart-enough" compiler.

Since I always compile with -Werror, this warning is causing
me a bit of grief.

Note that the targets which I have tested all have 32-bit
unsigned long integers.

enum{ bitNumber = 15};

void test(unsigned long* p)
{
    if(bitNumber < 8){
        *p   = (((unsigned long)0x01) << (bitNumber*4));
    }
}

% gcc -c biterr.c
biterr.c: In function `test':
biterr.c:6: warning: left shift count >= width of type


-- 
           Summary: warning: left shift count >= width of type
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mnmoran at bellsouth dot net


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26516


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [Bug c/26516] warning: left shift count >= width of type
  2006-03-01 18:57 [Bug c/26516] New: warning: left shift count >= width of type mnmoran at bellsouth dot net
@ 2006-03-01 19:02 ` pinskia at gcc dot gnu dot org
  0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-03-01 19:02 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-03-01 19:02 -------
This is just a duplicate of PR 4210 which talks about not warning for dead code
since this is dead code after all since 15 < 8 is false.

*** This bug has been marked as a duplicate of 4210 ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26516


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-03-01 19:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-01 18:57 [Bug c/26516] New: warning: left shift count >= width of type mnmoran at bellsouth dot net
2006-03-01 19:02 ` [Bug c/26516] " 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).