This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/52708] suboptimal code with __builtin_constant_p
- From: "tijl at coosemans dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sun, 25 Mar 2012 20:09:34 +0000
- Subject: [Bug c/52708] suboptimal code with __builtin_constant_p
- Auto-submitted: auto-generated
- References: <bug-52708-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52708
--- Comment #1 from Tijl Coosemans <tijl at coosemans dot org> 2012-03-25 20:09:34 UTC ---
(In reply to comment #0)
> Consider the following code:
>
> --------------------
> #include <stdio.h>
>
> int bar(void) __attribute__((__const__));
>
> int main( int argc, char **argv ) {
> int res;
>
> res = (__builtin_constant_p(bar()) ? 0 : 1);
> printf( "%d\n", res );
>
> res = (__builtin_constant_p(bar()) ? 0 : bar());
> printf( "%d\n", res );
>
> return(0);
> }
> --------------------
"bar" should have been "foo" here, to match the surrounding text.