Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 355109 - sys-devel/gcc-4.4.4-r2 inappropriately predefines 'bool' if option -maltivec is used on ppc or ppc64
Summary: sys-devel/gcc-4.4.4-r2 inappropriately predefines 'bool' if option -maltivec ...
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] GCC Porting (show other bugs)
Hardware: PPC64 Linux
: High normal (vote)
Assignee: Gentoo Toolchain Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-15 20:51 UTC by Stephen Lewis
Modified: 2011-02-17 05:30 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephen Lewis 2011-02-15 20:51:49 UTC
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
Comment 1 Stephen Lewis 2011-02-16 05:47:20 UTC
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
Comment 2 SpanKY gentoo-dev 2011-02-17 05:30:43 UTC
include <stdbool.h> if you want to use "bool"