Bug 127606

Summary: __builtin_expect's prototype does not expect int args; assert feeds it just that
Product: [Fedora] Fedora Reporter: D. Hugh Redelmeier <hugh>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 2CC: drepper, hugh
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-10-04 07:42:44 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description D. Hugh Redelmeier 2004-07-10 19:53:59 UTC
Description of problem:
gcc -Wconversion will always complain about invocations of the assert
macro.  Apparently a boolean expression (i.e. of type int) is not
accepted by __builtin_expect, which is called by the assert macro.

Version-Release number of selected component (if applicable):
gcc-3.3.3-7 (for AMD 64)


How reproducible:
Always.

Steps to Reproduce:
1.
cat >t.c <<\EOF
#include <assert.h>

int
main()
{
    assert(1);
    assert(1L);
    assert(1LL);
    assert(&main);
    return 0;
}
EOF
2.gcc -Wconversion t.c

  
Actual results:
t.c: In function `main':
t.c:6: warning: passing arg 1 of `__builtin_expect' with different
width due to prototype
t.c:6: warning: passing arg 2 of `__builtin_expect' with different
width due to prototype
t.c:7: warning: passing arg 1 of `__builtin_expect' with different
width due to prototype
t.c:7: warning: passing arg 2 of `__builtin_expect' with different
width due to prototype
t.c:8: warning: passing arg 1 of `__builtin_expect' with different
width due to prototype
t.c:8: warning: passing arg 2 of `__builtin_expect' with different
width due to prototype
t.c:9: warning: passing arg 1 of `__builtin_expect' with different
width due to prototype
t.c:9: warning: passing arg 2 of `__builtin_expect' with different
width due to pro

Expected results:
[silence, certainly for line 6, but probably for the others as well]

Additional info:

After preprocessing, the first assert becomes:
    ((void) (__builtin_expect (!!(1), 1) ? 0 : (__assert_fail ("1",
"t.c", 6, __PRETTY_FUNCTION__), 0)));
There is nothing suspicious about the arguments to __builtin_expect.

This might be related to 
<https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=103017>

Comment 1 Ulrich Drepper 2004-10-04 07:42:44 UTC
I've removed __builtin_expect from the upstream glibc.  The result
will be in FC3 rawhide soon.

Comment 2 Jakub Jelinek 2004-10-06 18:32:42 UTC
The patch is in glibc-2.3.2-95.28 which ought to appear in U4 beta.

Comment 3 John Flanagan 2004-12-20 18:14:13 UTC
An errata has been issued which should help the problem 
described in this bug report. This report is therefore being 
closed with a resolution of ERRATA. For more information
on the solution and/or where to find the updated files, 
please follow the link below. You may reopen this bug report 
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2004-586.html