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]

extra warnings about shift count in a template


Problem: extra warnings about shift count in a template.
I don't think this program should result in any warnings.

When I compile the program below with this:

gxx -O2 -Wall temp.cpp -o temp.exe

I get these warnings:

temp.cpp: In function `void search_sub<32>()':
temp.cpp:19:   instantiated from `search_sub<16>()'
temp.cpp:19:   instantiated from `search_sub<0>()'
temp.cpp:24:   instantiated from here
temp.cpp:11: warning: left shift count >= width of type
temp.cpp: In function `void search_sub<48>()':
temp.cpp:19:   instantiated from `search_sub<32>()'
temp.cpp:19:   instantiated from `search_sub<16>()'
temp.cpp:19:   instantiated from `search_sub<0>()'
temp.cpp:24:   instantiated from here
temp.cpp:11: warning: left shift count >= width of type
temp.cpp: In function `void search_sub<64>()':
temp.cpp:19:   instantiated from `search_sub<48>()'
temp.cpp:19:   instantiated from `search_sub<32>()'
temp.cpp:19:   instantiated from `search_sub<16>()'
temp.cpp:19:   instantiated from `search_sub<0>()'
temp.cpp:24:   instantiated from here
temp.cpp:11: warning: left shift count >= width of type
temp.cpp:14: warning: left shift count >= width of type
temp.cpp: In function `void search_sub<65>()':
temp.cpp:19:   instantiated from `search_sub<64>()'
temp.cpp:19:   instantiated from `search_sub<48>()'
temp.cpp:19:   instantiated from `search_sub<32>()'
temp.cpp:19:   instantiated from `search_sub<16>()'
temp.cpp:19:   instantiated from `search_sub<0>()'
temp.cpp:24:   instantiated from here
temp.cpp:11: warning: left shift count >= width of type
temp.cpp:14: warning: left shift count >= width of type

----------------- temp.cpp -------------------------
#include <stdio.h>

#define MIN(x,y) (((x) < (y)) ? (x) : (y))
#define MAX(x,y) (((x) > (y)) ? (x) : (y))

template< int i>
void search_sub()
{
  if ( i >= 0 ) {
    if ( i<32 ) {
      int t = 1<<i;
      printf( "p2: i = %d, t = %x\n", i, t);
    } else if ( i<64 ) {
      long long t = ((long long)(1))<<i;
      printf( "p3: i = %d, t = %llx\n", i, t);
    }
  }
  if ( i <= 64 )
    search_sub< MIN(i+16, 65)>();
}

int main( int argc, char** argv)
{
  search_sub<0>();
  return 0;
}
--------------------------- cut here --------------------

Here is the version information:

Sat 01-29-2000 19:49:14.58 C:\0\gcc\template>gxx -v
Reading specs from c:/djgpp/lib/gcc-lib/djgpp/2.952/specs
gcc version 2.95.2 19991024 (release)
 c:/djgpp/lib/gcc-lib/djgpp/2.952/collect2.exe c:/djgpp/lib/crt0.o
-Lc:/djgpp/li
b -Lc:/djgpp/lib/gcc-lib/djgpp/2.952 -Lc:/djgpp/bin -Lc:/djgpp/lib -lgpp
-lstdcx
x -lm -lgcc -lc -lgcc -Tdjgpp.djl
c:/djgpp/lib/crt0.o(.data+0xc2):crt0.s: undefined reference to `main'
c:/djgpp/lib/libc.a(crt1.o)(.text+0x44e):crt1.c: undefined reference to
`main'
collect2: ld returned 1 exit status

Dennis Yelle

-- 
Please play with my new Java toy:
http://www.fortunecity.com/roswell/barada/186/chaos/
(If you and your browser ever do that sort of thing.)

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