On Tue, Dec 17, 2013 at 06:17:01PM +0100, Marek Polacek wrote:
> Regtested on x86_64-linux with -m32/-m64.
> 
> Ok?
> 
> 2013-12-17  Marek Polacek  <pola...@redhat.com>
> 
> testsuite/
>       * c-c++-common/ubsan/overflow-int128.c: New test.
> 
> --- gcc/testsuite/c-c++-common/ubsan/overflow-int128.c.mp     2013-12-17 
> 16:54:28.123468111 +0100
> +++ gcc/testsuite/c-c++-common/ubsan/overflow-int128.c        2013-12-17 
> 18:07:19.539221035 +0100
> @@ -0,0 +1,48 @@
> +/* { dg-do run } */
> +/* { dg-require-effective-target int128 } */
> +/* { dg-options "-fsanitize=signed-integer-overflow -Wno-overflow" } */
> +/* { dg-skip-if "" { *-*-* } { "-flto" } { "" } } */
> +
> +/* 2^127 - 1 */
> +#define INT128_MAX (((__int128) 1 << ((__SIZEOF_INT128__ * __CHAR_BIT__) - 
> 1)) - 1)

Isn't this undefined behavior in C?  I mean, shouldn't you
shift up (unsigned __int128) 1 and only cast to (__int128) at the end?

        Jakub

Reply via email to