Bug 37866 - "passing argument from incompatible pointer type" warning cannot be passed to -Werror=
Summary: "passing argument from incompatible pointer type" warning cannot be passed to...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 4.3.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-17 22:24 UTC by Diego Elio Pettenò
Modified: 2014-10-12 13:18 UTC (History)
5 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build: x86_64-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2009-07-06 16:48:29


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Diego Elio Pettenò 2008-10-17 22:24:27 UTC
The new -Werror= option for GCC 4.3 is very useful to make GCC error out for specific warnings, but it currently lacks a way to make that warning an error (which is very useful to avoid skipping parameters in fprintf()-like functions.

Even -fdiagnostics-show-option suggested by the manual doesn't show an option name near those warnings, which seems to be available only with -Wall.
Comment 1 Andrew Pinski 2008-10-17 22:34:54 UTC
That is because this is a pedantic warning which is enabled by default.
Comment 2 Diego Elio Pettenò 2008-10-17 22:36:56 UTC
Which gives it even more usefulness to be optionally treated as an error, since it really helps to avoid shooting oneself in the foot...

I guess it would be bad to have a way to -Wno- it, but it would be nice to at least being able to -Werror= it...
Comment 3 Diego Elio Pettenò 2008-11-13 17:20:04 UTC
The same happens for "assignment makes integer from pointer without a cast" . It really is not nice that these warnings cannot be made errors explicitly, they are _quite_ important.
Comment 4 Viktor Bachraty 2008-12-02 15:33:21 UTC
I had some issues caused by implicit pointer casting as well. Would be really nice to be able to separately turn specific classes of pedantic warnings into errors without having to turn every warning.
Comment 5 Manuel López-Ibáñez 2009-07-06 16:48:28 UTC
We could add an OPT_Wdefault that replaces 0 in pedwarn(loc, 0, "message"), then -Werror=default would turn all default warnings into errors. And -Wno-default will turn off default warnings that cannot be currently controlled.

Diego, would that satisfy you?

If we want further fine control, we would need to add further -Wxxx options for specific default warnings.
Comment 6 Diego Elio Pettenò 2009-07-06 17:03:48 UTC
To be honest there are quite a few default warnings that I wouldn't want to turn into errors, but it would still be better than having _no_ way to get this into an error.
Comment 7 Russ Cox 2009-09-09 23:30:04 UTC
There is a difference between warnings about things that might
be wrong in your code and warnings about things that are definitely wrong.
This is one of the latter, and it is a shame that it's not already an error
by default.  I understand the historical rationale but it is still unfortunate.
integer/pointer without a cast is another one.  If I could make these
errors I most certainly would.  As it is I run gcc in a wrapper script
and exit 1 if gcc emits that particular warning.
Comment 8 Manuel López-Ibáñez 2009-09-10 15:14:54 UTC
Pedantic warnings may be controlled by individual warning flags. So to fix this you only need to:

* add a new -Wfoo option to c.opt that is enabled by default.
* use the option in the appropriate warning calls in c-typeck.c
* create some testcases to show that it works.
* get the patch reviewed and committed.

Patches welcome: http://gcc.gnu.org/contribute.html

Comment 9 Manuel López-Ibáñez 2014-10-12 13:18:41 UTC
https://gcc.gnu.org/gcc-5/changes.html

It is possible to disable warnings about conversions between pointers that have incompatible types via a new warning option -Wno-incompatible-pointer-types; warnings about implicit incompatible integer to pointer and pointer to integer conversions via a new warning option -Wno-int-conversion; and warnings about qualifiers on pointers being discarded via a new warning option -Wno-discarded-qualifiers.