advancetoolchain / advance-toolchain

Advance Toolchain for Linux on Power build system.
https://www.ibm.com/support/pages/advance-toolchain-linux-power
Apache License 2.0
35 stars 27 forks source link

compilation error (-std=gnu++14 ) : altivec types aliases with 'using' keyword and macros preprocessor in the same file #1861

Open quickwritereader opened 3 years ago

quickwritereader commented 3 years ago
#include <altivec.h>
using vdbl =  __vector double;

#define BREAK 1

workaround 0: -std=c++14 workaround 1: typedef __vector double vdbl; workaround 2: using vdbl = __attribute__((altivec(vector__))) double; workaround 3: putting dummy function between void dummy(){};

quickwritereader commented 3 years ago

https://godbolt.org/z/o6eoo4

Flamefire commented 3 years ago

This is intresting indeed. I also found there is some dependency on maltivec vs mvsx and ppc vs ppcle: https://godbolt.org/z/4bGsh8 It seems to swallow what comes after __vector

mscastanho commented 3 years ago

I was able to reproduce it on AT 14:

$ cat /tmp/test-vector.c 
#include <altivec.h>
using vdbl =  __vector double;
#define BREAK 1
$ /opt/at14.0/bin/g++ -c /tmp/test-vector.c 
/tmp/test-vector.c:4:15: error: expected type-specifier before numeric constant
    4 | #define BREAK 1
      |               ^
/tmp/test-vector.c:4:9: note: in expansion of macro ‘BREAK’
    4 | #define BREAK 1
      |         ^~~~~
$ /opt/at14.0/bin/g++ -c /tmp/test-vector.c -std=c++14
$
mscastanho commented 3 years ago

@quickwritereader This looks like a general GCC bug, not limited to AT. Could you open a bug report upstream (gcc.gnu.org/bugzilla), please? Thanks!

tuliom commented 3 years ago

AFAICS, this issue is still broken on AT 14. I'm reopening this issue so that we can use it to track the fix downstream.

tuliom commented 3 years ago

I didn't find a bug report upstream for this issue, so I reported it: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101168