[Bug 1720959] Re: Bug with LTO optimizations in G++?

Vasco Alexandre da Silva Costa 1720959 at bugs.launchpad.net
Tue Oct 3 07:21:36 UTC 2017


gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)


** Description changed:

  This code shows the bug:
  ---
  #include <stdio.h>
  
  typedef __attribute__ ((__aligned__ (16))) struct _TEST_FLOAT128 {
-     __extension__ unsigned long long Part[2];
+     __extension__ unsigned long long Part[2];
  } TEST_FLOAT128;
  
  int main( void )
  {
-     TEST_FLOAT128 tf;
-     printf( "alignof(tf) = %d\n",(int)__alignof__(tf) );
+     TEST_FLOAT128 tf;
+     printf( "alignof(tf) = %d\n",(int)__alignof__(tf) );
  
-     printf( "alignof(struct _TEST_FLOAT128) = %d\n",(int)__alignof__(struct _TEST_FLOAT128) );
-     printf( "alignof(TEST_FLOAT128) = %d\n",(int)__alignof__(TEST_FLOAT128) );
+     printf( "alignof(struct _TEST_FLOAT128) = %d\n",(int)__alignof__(struct _TEST_FLOAT128) );
+     printf( "alignof(TEST_FLOAT128) = %d\n",(int)__alignof__(TEST_FLOAT128) );
  
-     return 0;
+     return 0;
  }
  ---
  
  $ g++-4.9 -O3 -flto -oalign test.cc -Wall -Wextra -g
  # compiles without warnings.
  
  $ g++-5 -O3 -flto -oalign test.cc -Wall -Wextra -g
- 1.cc:3:51: warning: type ‘struct _TEST_FLOAT128’ violates one definition rule [-Wodr]
-  typedef __attribute__ ((__aligned__ (16))) struct _TEST_FLOAT128 {
-                                                    ^
- 1.cc:5:3: note: a type with different alignment is defined in another translation unit
-  } TEST_FLOAT128;
-    ^
+ test.cc:3:51: warning: type ‘struct _TEST_FLOAT128’ violates one definition rule [-Wodr]
+  typedef __attribute__ ((__aligned__ (16))) struct _TEST_FLOAT128 {
+                                                    ^
+ test.cc:5:3: note: a type with different alignment is defined in another translation unit
+  } TEST_FLOAT128;
+    ^
  # triggers a warning.

** Description changed:

  This code shows the bug:
- ---
+ ---test.cc---
  #include <stdio.h>
  
  typedef __attribute__ ((__aligned__ (16))) struct _TEST_FLOAT128 {
      __extension__ unsigned long long Part[2];
  } TEST_FLOAT128;
  
  int main( void )
  {
      TEST_FLOAT128 tf;
      printf( "alignof(tf) = %d\n",(int)__alignof__(tf) );
  
      printf( "alignof(struct _TEST_FLOAT128) = %d\n",(int)__alignof__(struct _TEST_FLOAT128) );
      printf( "alignof(TEST_FLOAT128) = %d\n",(int)__alignof__(TEST_FLOAT128) );
  
      return 0;
  }
  ---
  
  $ g++-4.9 -O3 -flto -oalign test.cc -Wall -Wextra -g
  # compiles without warnings.
  
  $ g++-5 -O3 -flto -oalign test.cc -Wall -Wextra -g
  test.cc:3:51: warning: type ‘struct _TEST_FLOAT128’ violates one definition rule [-Wodr]
   typedef __attribute__ ((__aligned__ (16))) struct _TEST_FLOAT128 {
                                                     ^
  test.cc:5:3: note: a type with different alignment is defined in another translation unit
   } TEST_FLOAT128;
     ^
  # triggers a warning.

-- 
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to gcc-5 in Ubuntu.
https://bugs.launchpad.net/bugs/1720959

Title:
  Bug with LTO optimizations in G++?

Status in gcc-5 package in Ubuntu:
  New

Bug description:
  This code shows the bug:
  ---test.cc---
  #include <stdio.h>

  typedef __attribute__ ((__aligned__ (16))) struct _TEST_FLOAT128 {
      __extension__ unsigned long long Part[2];
  } TEST_FLOAT128;

  int main( void )
  {
      TEST_FLOAT128 tf;
      printf( "alignof(tf) = %d\n",(int)__alignof__(tf) );

      printf( "alignof(struct _TEST_FLOAT128) = %d\n",(int)__alignof__(struct _TEST_FLOAT128) );
      printf( "alignof(TEST_FLOAT128) = %d\n",(int)__alignof__(TEST_FLOAT128) );

      return 0;
  }
  ---

  $ g++-4.9 -O3 -flto -oalign test.cc -Wall -Wextra -g
  # compiles without warnings.

  $ g++-5 -O3 -flto -oalign test.cc -Wall -Wextra -g
  test.cc:3:51: warning: type ‘struct _TEST_FLOAT128’ violates one definition rule [-Wodr]
   typedef __attribute__ ((__aligned__ (16))) struct _TEST_FLOAT128 {
                                                     ^
  test.cc:5:3: note: a type with different alignment is defined in another translation unit
   } TEST_FLOAT128;
     ^
  # triggers a warning.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1720959/+subscriptions



More information about the foundations-bugs mailing list