| Summary: | sys-devel/gcc-4.4.4-r2 inappropriately predefines 'bool' if option -maltivec is used on ppc or ppc64 | ||
|---|---|---|---|
| Product: | Gentoo Linux | Reporter: | Stephen Lewis <lewis+gentoo> |
| Component: | [OLD] GCC Porting | Assignee: | Gentoo Toolchain Maintainers <toolchain> |
| Status: | RESOLVED INVALID | ||
| Severity: | normal | CC: | ppc64, ppc |
| Priority: | High | ||
| Version: | unspecified | ||
| Hardware: | PPC64 | ||
| OS: | Linux | ||
| Whiteboard: | |||
| Package list: | Runtime testing required: | --- | |
On further study this seems to be a feature and not a bug
info gcc for 4.3.4 says:
* Compiling with `-maltivec' adds keywords `__vector', `__pixel',
and `__bool'. Macros `vector', `pixel', and `bool' are defined in
`<altivec.h>' and can be undefined.
info gcc 4.4.4 has been changed to say:
* Compiling with `-maltivec' adds keywords `__vector', `vector',
`__pixel', `pixel', `__bool' and `bool'. When compiling ISO C,
the context-sensitive substitution of the keywords `vector',
`pixel' and `bool' is disabled. To use them, you must include
`<altivec.h>' instead.
So I guess code using the (now) keyword 'bool' (or 'vector' or 'pixel') needs to be changed to comply with compiler change in 4.4.4 or the option -maltivec should not be applied during compilation
include <stdbool.h> if you want to use "bool" |
If gcc 4.4.4 is invoked with -maltivec on ppc or ppc64 it predefined 'bool' which gcc 4.3.4 and earlier do not. This causes programs like this which work on 4.3.4 to fail to compile on 4.4.4 #ifndef bool typedef int bool; const bool true = 1; const bool false = 0; #endif int main(int argc,char *argv[]) { bool b = false; return b; } Reproducible: Always Steps to Reproduce: 1. gcc -Wall -maltivec test.c # test code given under description 2. 3. Actual Results: result with 4.4.4 is: test.c: In function main: test.c:8: error: bool undeclared (first use in this function) test.c:8: error: (Each undeclared identifier is reported only once test.c:8: error: for each function it appears in.) test.c:8: error: expected ; before b test.c:9: error: b undeclared (first use in this function) Expected Results: with gcc 4.3.4 test code compiles and works fine the problem can be seen by printing the predefined macros thusly: $ touch /tmp/empty.c && /usr/powerpc64-unknown-linux-gnu/gcc-bin/4.4.4/powerpc64-unknown-linux-gnu-cpp -dM -maltivec /tmp/empty.c | grep bool #define bool bool #define __bool __attribute__((altivec(bool__))) unsigned $ touch /tmp/empty.c && /usr/powerpc64-unknown-linux-gnu/gcc-bin/4.3.4/powerpc64-unknown-linux-gnu-cpp -dM -maltivec /tmp/empty.c | grep bool #define __bool __attribute__((altivec(bool__))) unsigned