public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/38116]  New: Excessive warnings when using assert and -Wconversion on 64bit platforms
@ 2008-11-14 14:17 paulf at free dot fr
  2008-11-14 23:14 ` [Bug c/38116] " pinskia at gcc dot gnu dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: paulf at free dot fr @ 2008-11-14 14:17 UTC (permalink / raw)
  To: gcc-bugs

/* foo.c */
#include <assert.h>

void foo(void)
{
   assert(1);
}

gcc -c -Wconversion foo.c
foo.c:6: warning: passing argument 1 of '__builtin_expect' with different width
due to prototype
foo.c:6: warning: passing argument 2 of '__builtin_expect' with different width
due to prototype

This is because assert() boils down to
__builtin_expect (!!(expr), 1), which means that __builtin_expect is called
with two int arguments. However, the signature of __builtin_expect is

long int __builtin_expect (long int exp, long int val)

Hence two warnings for the conversion of int to long int.

This greatly limits the usefulness of -Wconversion.


-- 
           Summary: Excessive warnings when using assert and -Wconversion on
                    64bit platforms
           Product: gcc
           Version: 4.0.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: paulf at free dot fr


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/38116] Excessive warnings when using assert and -Wconversion on 64bit platforms
  2008-11-14 14:17 [Bug c/38116] New: Excessive warnings when using assert and -Wconversion on 64bit platforms paulf at free dot fr
@ 2008-11-14 23:14 ` pinskia at gcc dot gnu dot org
  2008-11-15 20:53 ` paulf at free dot fr
  2008-11-16  2:43 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-11-14 23:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from pinskia at gcc dot gnu dot org  2008-11-14 23:13 -------


*** This bug has been marked as a duplicate of 6614 ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/38116] Excessive warnings when using assert and -Wconversion on 64bit platforms
  2008-11-14 14:17 [Bug c/38116] New: Excessive warnings when using assert and -Wconversion on 64bit platforms paulf at free dot fr
  2008-11-14 23:14 ` [Bug c/38116] " pinskia at gcc dot gnu dot org
@ 2008-11-15 20:53 ` paulf at free dot fr
  2008-11-16  2:43 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: paulf at free dot fr @ 2008-11-15 20:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from paulf at free dot fr  2008-11-15 20:51 -------
I do not agree that this is a duplicate of 6614. 6614 is a consequence of
integer promotion, and there is no possible user code change that would make it
go away (other than avoiding integral types smaller than int in function
arguments).

This bug could be fixed by using the correct types in the assert macro, e.g.,

__builtin_expect ((long int)!!(expr), 1L)


-- 

paulf at free dot fr changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|DUPLICATE                   |


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Bug c/38116] Excessive warnings when using assert and -Wconversion on 64bit platforms
  2008-11-14 14:17 [Bug c/38116] New: Excessive warnings when using assert and -Wconversion on 64bit platforms paulf at free dot fr
  2008-11-14 23:14 ` [Bug c/38116] " pinskia at gcc dot gnu dot org
  2008-11-15 20:53 ` paulf at free dot fr
@ 2008-11-16  2:43 ` pinskia at gcc dot gnu dot org
  2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-11-16  2:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2008-11-16 02:42 -------
Except assert is controlled by your libc and not GCC so this is still really PR
6614.  Also 4.3 changed the definition of -Wconversion so it does not matter
any more.

*** This bug has been marked as a duplicate of 6614 ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE


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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-11-16  2:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-14 14:17 [Bug c/38116] New: Excessive warnings when using assert and -Wconversion on 64bit platforms paulf at free dot fr
2008-11-14 23:14 ` [Bug c/38116] " pinskia at gcc dot gnu dot org
2008-11-15 20:53 ` paulf at free dot fr
2008-11-16  2:43 ` pinskia at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).