https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88100

            Bug ID: 88100
           Summary: no warning reported when value for
                    vec_splat_{su}{8,16} would overflow
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pc at gcc dot gnu.org
  Target Milestone: ---

Created attachment 45036
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45036&action=edit
test case

$ cat bug.c
#include <altivec.h>
void foo() {
  signed char cs0 = 0x100;
  unsigned char cu0= 0x100;
  signed short ss0 = 0x10000;
  unsigned short su0= 0x10000;
  signed int is0 = 0x100000000;
  unsigned int iu0= 0x100000000;
  vector signed char v8 = vec_splat_s8(256);
  vector unsigned char v11 = vec_splat_u8(256);
  vector signed short v12 = vec_splat_s16(0x10000);
  vector unsigned short v13 = vec_splat_u16(0x10000);
  vector signed int v14 = vec_splat_s32(0x100000000);
  vector unsigned int v15 = vec_splat_u32(0x100000000);
}
$ gcc -c bug.c
bug.c: In function ‘foo’:
bug.c:3:21: warning: overflow in conversion from ‘int’ to ‘signed char’ changes
value from ‘256’ to ‘0’ [-Woverflow]
   signed char cs0 = 0x100;
                     ^~~~~
bug.c:4:22: warning: unsigned conversion from ‘int’ to ‘unsigned char’ changes
value from ‘256’ to ‘0’ [-Woverflow]
   unsigned char cu0= 0x100;
                      ^~~~~
bug.c:5:22: warning: overflow in conversion from ‘int’ to ‘short int’ changes
value from ‘65536’ to ‘0’ [-Woverflow]
   signed short ss0 = 0x10000;
                      ^~~~~~~
bug.c:6:23: warning: unsigned conversion from ‘int’ to ‘short unsigned int’
changes value from ‘65536’ to ‘0’ [-Woverflow]
   unsigned short su0= 0x10000;
                       ^~~~~~~
bug.c:7:20: warning: overflow in conversion from ‘long int’ to ‘int’ changes
value from ‘4294967296’ to ‘0’ [-Woverflow]
   signed int is0 = 0x100000000;
                    ^~~~~~~~~~~
bug.c:8:21: warning: unsigned conversion from ‘long int’ to ‘unsigned int’
changes value from ‘4294967296’ to ‘0’ [-Woverflow]
   unsigned int iu0= 0x100000000;
                     ^~~~~~~~~~~
bug.c:13:27: warning: overflow in conversion from ‘long int’ to ‘int’ changes
value from ‘4294967296’ to ‘0’ [-Woverflow]
   vector signed int v14 = vec_splat_s32(0x100000000);
                           ^~~~~~~~~~~~~
bug.c:14:29: warning: overflow in conversion from ‘long int’ to ‘int’ changes
value from ‘4294967296’ to ‘0’ [-Woverflow]
   vector unsigned int v15 = vec_splat_u32(0x100000000);
                             ^~~~~~~~~~~~~
--
Note: no warnings for the vector char and vector short types.

Reply via email to