This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug other/58241] [PPC/Altivec] altivec.h inclusion in -std=c++98..11 causes bool to be redefined


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

--- Comment #7 from Francisco Jerez <currojerez at riseup dot net> ---
(In reply to Andrew Pinski from comment #6)
> (In reply to Francisco Jerez from comment #5)
> > (In reply to Andrew Pinski from comment #3)
> > > You need to use -std=g++11 or undefine bool after the include of altivec.h
> > > as context sensitive keywords is not part of the C++11 standard.
> > > 
> > 
> > Isn't the bool keyword part of the C++ standard?  I fail to see how this bug
> > is invalid, the inclusion of a system header is redefining the meaning of a
> > language keyword in a way that breaks standard C++ code, and the definition
> > of "vector" collides with the C++ standard library.
> 
> Yes bool is a keyword fully in the C++ standard.  A system header which is
> defined by the AltiVec (VMX) PIM to maybe define bool in the header.
> 

Apparently the AltiVec PIM gives two possibilities to the
implementation:

| 2.2.1 The Keyword and Predefine Method
|
| In this method, __vector, __pixel, and bool are added as
| keywords while vector and pixel are predefined macros. bool is
| already a keyword in C++. To allow its use in C as a keyword,
| it is treated the same as it is in C++. This means that the C
| language is extended to allow bool alone as a set of type
| specifiers. Typically, this type will map to int. [...]
|
| 2.2.2 The Context Sensitive Keyword Method
|
| In this method, __vector and __pixel are added as keywords
| without regard to context while the new uses of vector, pixel,
| and bool are keywords only in the context of a type. [...]

I understand that what is described in section 2.2.2 might not be
possible to achieve in standard C++ mode, so GCC's implementation
would be expected to stick to section 2.2.1, which also involves
treating bool as a keyword as it is in standard C++.

This makes me think that the intention of the authors was to
preserve the usual semantics of bool in C++ programs except where
it's used in conjunction with the __vector type specifier, so
code like "bool a = (b == 0);" (which is being rejected in
ChÃ-Thanh's set-up) would still be valid in presence of the
AltiVec extensions.

Am I missing something?

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]