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



             Bug #: 55544

           Summary: invalid optimisation long long->double->long long

                    (with -m32)

    Classification: Unclassified

           Product: gcc

           Version: unknown

            Status: UNCONFIRMED

          Severity: normal

          Priority: P3

         Component: c

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: joerg.rich...@pdv-fs.de





$ cat t.c

#include <stdio.h>

int main( int argc, char** argv )

{

  long long v1;

  sscanf( argv[1], "%lld", &v1 );

  double d = (double)v1;

  long long v2 = (long long)d;

  printf( "v1=%lld d=%19.0f v2=%lld\n", v1, d, v2 );

  return 0;

}



$ gcc -m32 -O -o t t.c

$ t 9223372036854774781

v1=9223372036854774781 d=9223372036854774784 v2=9223372036854774781



please note that v1 == v2.  This is wrong



$ gcc -m32 -o t t.c

$ t 9223372036854774781

v1=9223372036854774781 d=9223372036854774784 v2=9223372036854774784



v2 == d.  This is correct

-m64 (with or without optimisation) works too

Reply via email to