Bug 41142 - make implicit pointer conversions an error when sizeof(int) != sizeof(void *)
Summary: make implicit pointer conversions an error when sizeof(int) != sizeof(void *)
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.3.4
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2009-08-21 16:49 UTC by dann frazier
Modified: 2019-09-29 18:39 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2017-02-07 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description dann frazier 2009-08-21 16:49:48 UTC
Implicit pointer conversions on ia64 are guaranteed to result in a segfault if the value is dereferenced. This issue can be easily identified by looking for a combination of gcc warnings. In fact, I have been running all of the build logs or the Debian distribution through a script that scans for this issue for several years, and it has caught hundreds of these problems:

http://bugs.debian.org/cgi-bin/pkgreport.cgi?users=dannf@debian.org;which=tag&data=implicit-pointer-conversion&archive=no

script here: http://people.debian.org/~dannf/check-implicit-pointer-functions

I don't know anything about gcc internals, but I'm wondering if it is possible to generate an error when the appropriate combination of warning conditions is present?
Comment 1 Jonathan Wakely 2009-08-21 17:03:07 UTC
-Werror=int-to-pointer-cast will make one class of warnings into errors, but I don't think there's a switch to handle the other cases your script detects.

Comment 2 Martin Sebor 2017-02-07 23:10:51 UTC
There has been no update on this request in over 7 years.  Is it still relevant (especially in light of comment #1)?  If so, can you provide more details?  I.e., what warnings specifically would you like to treat as errors that -Werror=warning-name doesn't let you do?  Like so:

$ cat t.c && /build/gcc-git/gcc/xgcc -B /build/gcc-git/gcc -O0 -S -Wall -Werror=int-conversion t.c
int f (void*);
void* g (void)
{
  char *s = f (0);
  f (123);
  s = 345;
  return 456;
}
t.c: In function ‘g’:
t.c:4:13: error: initialization makes pointer from integer without a cast [-Werror=int-conversion]
   char *s = f (0);
             ^
t.c:5:6: error: passing argument 1 of ‘f’ makes pointer from integer without a cast [-Werror=int-conversion]
   f (123);
      ^~~
t.c:1:5: note: expected ‘void *’ but argument is of type ‘int’
 int f (void*);
     ^
t.c:6:5: error: assignment makes pointer from integer without a cast [-Werror=int-conversion]
   s = 345;
     ^
t.c:7:10: error: return makes pointer from integer without a cast [-Werror=int-conversion]
   return 456;
          ^~~
t.c:4:9: warning: variable ‘s’ set but not used [-Wunused-but-set-variable]
   char *s = f (0);
         ^
cc1: some warnings being treated as errors
Comment 3 Martin Sebor 2019-09-29 18:39:17 UTC
Closing due to no feedback.