Bug 93750 - Altivec and std=c++11
Summary: Altivec and std=c++11
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 10.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL: https://redmine.gromacs.org/issues/3380
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-14 23:33 UTC by Christoph Junghans
Modified: 2020-02-15 02:13 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christoph Junghans 2020-02-14 23:33:48 UTC
If I have a code like:
#include<altivec.h>
int main(){vector double x,y=vec_splats(1.0);x=vec_madd(y,y,y);return vec_all_ge(y,x);}

It compiled gcc-9 (g++ -std=c++11 code.c), but fails with gcc-10 (without "-std=c++11" gcc-10 will compile the code fine as well).

What is wrong here?
Comment 1 Andrew Pinski 2020-02-14 23:37:10 UTC
Does using -std=gnu++11 work?
Comment 2 Christoph Junghans 2020-02-14 23:38:41 UTC
(In reply to Andrew Pinski from comment #1)
> Does using -std=gnu++11 work?

It does indeed!
Comment 3 Jonathan Wakely 2020-02-15 02:13:03 UTC
altivec.h is clear:

/* If __APPLE_ALTIVEC__ is defined, the compiler supports 'vector',
   'pixel' and 'bool' as context-sensitive AltiVec keywords (in 
   non-AltiVec contexts, they revert to their original meanings,
   if any), so we do not need to define them as macros.  Also,
   avoid defining them as macros for C++ with strict ANSI, as
   this is not compatible.  */

#if !defined(__APPLE_ALTIVEC__) \
    && (!defined(__STRICT_ANSI__) || !defined(__cplusplus))
#define vector __vector
#define pixel __pixel
#define bool __bool
#endif

You can't use the non-standard 'vector' extension if you request strict c++11 mode.