Hello

Consider this source (which is partly from SETJMP_FLOAT128):

#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;
}


Compiled like this:
g++ -O3 -flto -oalign align.cpp -Wall -Wextra -g


I get the following warning:
align.cpp:4:51: warning: type 'struct _TEST_FLOAT128' violates one definition 
rule [-Wodr]
typedef __attribute__ ((__aligned__ (16))) struct _TEST_FLOAT128 {
align.cpp:6:3: note: a type with different alignment is defined in another 
translation unit
} TEST_FLOAT128;


And this output when run:
alignof(tf) = 16
alignof(struct _TEST_FLOAT128) = 8
alignof(TEST_FLOAT128) = 16



Now if I move the __aligned__ attribute after the struct like this:
typedef struct __attribute__ ((__aligned__ (16))) _TEST_FLOAT128 {
__extension__ unsigned long long Part[2];
} TEST_FLOAT128;



The warning is gone, and the alignment is the same everywhere:

alignof(tf) = 16
alignof(struct _TEST_FLOAT128) = 16
alignof(TEST_FLOAT128) = 16


Is the warning correct, even thou the names are slightly different 
(with/without underscore)?
Should the attribute be moved in SETJMP_FLOAT128?


Regards
Domani Hannes

------------------------------------------------------------------------------
Transform Data into Opportunity.
Accelerate data analysis in your applications with
Intel Data Analytics Acceleration Library.
Click to learn more.
http://pubads.g.doubleclick.net/gampad/clk?id=278785231&iu=/4140
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to