* [Bug c/36299] spurious and undocumented warning with -Waddress for a == 0 when a is an array
[not found] <bug-36299-4@http.gcc.gnu.org/bugzilla/>
@ 2011-03-01 9:14 ` manu at gcc dot gnu.org
2011-03-01 15:05 ` vincent at vinc17 dot org
` (8 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: manu at gcc dot gnu.org @ 2011-03-01 9:14 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36299
--- Comment #4 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2011-03-01 09:14:27 UTC ---
(In reply to comment #3)
>
> The documentation should be improved anyway (the word "suspicious" is very
> subjective).
>
Please propose a patch.
> > You should be able to work-around the macro case by casting the array to (char
> > *) or perhaps casting to (void *) ?
>
> Yes, this makes sense. Perhaps this should be documented.
Is it working? I meant to say "ideally" one should be able to do this but I
don't think it is working right now (and probably there are not testcases
testing this).
>
> How about something like __extension__, e.g. __no_warnings__ would disable the
> warnings for the following statement or expression? If expression, one could
There was a patch floating around in gcc-patches to implement that but since
GCC location info is far from perfect (especially on macro expansions), I think
it won't work well in practice. Moreover, the preferred way is to use the
existing diagnostic pragmas.
http://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Pragmas.html
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/36299] spurious and undocumented warning with -Waddress for a == 0 when a is an array
[not found] <bug-36299-4@http.gcc.gnu.org/bugzilla/>
2011-03-01 9:14 ` [Bug c/36299] spurious and undocumented warning with -Waddress for a == 0 when a is an array manu at gcc dot gnu.org
@ 2011-03-01 15:05 ` vincent at vinc17 dot org
2011-03-01 15:37 ` manu at gcc dot gnu.org
` (7 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: vincent at vinc17 dot org @ 2011-03-01 15:05 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36299
--- Comment #5 from Vincent Lefèvre <vincent at vinc17 dot org> 2011-03-01 15:05:19 UTC ---
Under Debian, I can no longer reproduce the problem with GCC 4.5.2:
$ gcc-4.5 -Wall warn-nulladdress.c
$ gcc-4.5 -Waddress warn-nulladdress.c
$ gcc-4.4 -Wall warn-nulladdress.c
warn-nulladdress.c: In function ‘main’:
warn-nulladdress.c:14: warning: the address of ‘a’ will never be NULL
$ gcc-4.4 -Waddress warn-nulladdress.c
warn-nulladdress.c: In function ‘main’:
warn-nulladdress.c:14: warning: the address of ‘a’ will never be NULL
So, I assume that it has been fixed anyway. Do you confirm?
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/36299] spurious and undocumented warning with -Waddress for a == 0 when a is an array
[not found] <bug-36299-4@http.gcc.gnu.org/bugzilla/>
2011-03-01 9:14 ` [Bug c/36299] spurious and undocumented warning with -Waddress for a == 0 when a is an array manu at gcc dot gnu.org
2011-03-01 15:05 ` vincent at vinc17 dot org
@ 2011-03-01 15:37 ` manu at gcc dot gnu.org
2011-03-02 1:15 ` vincent at vinc17 dot org
` (6 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: manu at gcc dot gnu.org @ 2011-03-01 15:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36299
--- Comment #6 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2011-03-01 15:37:25 UTC ---
(In reply to comment #5)
>
> So, I assume that it has been fixed anyway. Do you confirm?
I think the intention is to warn, at least for a == (void *)0, since the
address of a cannot be zero or null. So I would say that this is a regression.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/36299] spurious and undocumented warning with -Waddress for a == 0 when a is an array
[not found] <bug-36299-4@http.gcc.gnu.org/bugzilla/>
` (2 preceding siblings ...)
2011-03-01 15:37 ` manu at gcc dot gnu.org
@ 2011-03-02 1:15 ` vincent at vinc17 dot org
2011-03-02 10:52 ` manu at gcc dot gnu.org
` (5 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: vincent at vinc17 dot org @ 2011-03-02 1:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36299
--- Comment #7 from Vincent Lefèvre <vincent at vinc17 dot org> 2011-03-02 01:15:23 UTC ---
(In reply to comment #6)
> I think the intention is to warn, at least for a == (void *)0, since the
> address of a cannot be zero or null. So I would say that this is a regression.
But this is valid in C, and in practice, such a test can occur in macro
expansions: a macro can check whether some pointer is null before doing
something with it. There shouldn't be a warning in such a case.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/36299] spurious and undocumented warning with -Waddress for a == 0 when a is an array
[not found] <bug-36299-4@http.gcc.gnu.org/bugzilla/>
` (3 preceding siblings ...)
2011-03-02 1:15 ` vincent at vinc17 dot org
@ 2011-03-02 10:52 ` manu at gcc dot gnu.org
2011-03-02 15:17 ` vincent at vinc17 dot org
` (4 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: manu at gcc dot gnu.org @ 2011-03-02 10:52 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36299
--- Comment #8 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2011-03-02 10:51:51 UTC ---
(In reply to comment #7)
> (In reply to comment #6)
> > I think the intention is to warn, at least for a == (void *)0, since the
> > address of a cannot be zero or null. So I would say that this is a regression.
>
> But this is valid in C, and in practice, such a test can occur in macro
> expansions: a macro can check whether some pointer is null before doing
> something with it. There shouldn't be a warning in such a case.
Every warning warns about something valid in C, otherwise it would be an error
not a warning.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/36299] spurious and undocumented warning with -Waddress for a == 0 when a is an array
[not found] <bug-36299-4@http.gcc.gnu.org/bugzilla/>
` (4 preceding siblings ...)
2011-03-02 10:52 ` manu at gcc dot gnu.org
@ 2011-03-02 15:17 ` vincent at vinc17 dot org
2011-03-02 17:06 ` manu at gcc dot gnu.org
` (3 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: vincent at vinc17 dot org @ 2011-03-02 15:17 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36299
--- Comment #9 from Vincent Lefèvre <vincent at vinc17 dot org> 2011-03-02 15:17:33 UTC ---
(In reply to comment #8)
> Every warning warns about something valid in C, otherwise it would be an error
> not a warning.
No, for instance:
int main(void)
{
int i;
return i;
}
This is undefined behavior and detected by GCC, but one gets only a warning:
tst.c: In function ‘main’:
tst.c:4: warning: ‘i’ is used uninitialized in this function
Compare to a == 0 in the above testcase, which has a well-defined behavior.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/36299] spurious and undocumented warning with -Waddress for a == 0 when a is an array
[not found] <bug-36299-4@http.gcc.gnu.org/bugzilla/>
` (5 preceding siblings ...)
2011-03-02 15:17 ` vincent at vinc17 dot org
@ 2011-03-02 17:06 ` manu at gcc dot gnu.org
2011-03-11 15:15 ` vincent-gcc at vinc17 dot net
` (2 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: manu at gcc dot gnu.org @ 2011-03-02 17:06 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36299
Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |WAITING
Last reconfirmed| |2011.03.02 17:06:47
Ever Confirmed|0 |1
--- Comment #10 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2011-03-02 17:06:47 UTC ---
(In reply to comment #9)
> This is undefined behavior and detected by GCC, but one gets only a warning:
I am not going to waste time discussing the fine-points of what is a valid C
program. If you don't want this warning, please contribute a testcase to
gcc-patches@gcc.gnu.org, so this warning won't reappear in the future:
http://gcc.gnu.org/wiki/HowToPrepareATestcase
Otherwise, someone will come who thinks that this should be warned and they
will "fix it".
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/36299] spurious and undocumented warning with -Waddress for a == 0 when a is an array
[not found] <bug-36299-4@http.gcc.gnu.org/bugzilla/>
` (6 preceding siblings ...)
2011-03-02 17:06 ` manu at gcc dot gnu.org
@ 2011-03-11 15:15 ` vincent-gcc at vinc17 dot net
2011-04-01 19:36 ` jsm28 at gcc dot gnu.org
2014-06-30 19:38 ` mpolacek at gcc dot gnu.org
9 siblings, 0 replies; 13+ messages in thread
From: vincent-gcc at vinc17 dot net @ 2011-03-11 15:15 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36299
--- Comment #11 from Vincent Lefèvre <vincent-gcc at vinc17 dot net> 2011-03-11 15:15:16 UTC ---
(In reply to comment #10)
> If you don't want this warning, please contribute a testcase to
> gcc-patches@gcc.gnu.org, so this warning won't reappear in the future:
Done: http://gcc.gnu.org/ml/gcc-patches/2011-03/msg00624.html
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/36299] spurious and undocumented warning with -Waddress for a == 0 when a is an array
[not found] <bug-36299-4@http.gcc.gnu.org/bugzilla/>
` (7 preceding siblings ...)
2011-03-11 15:15 ` vincent-gcc at vinc17 dot net
@ 2011-04-01 19:36 ` jsm28 at gcc dot gnu.org
2014-06-30 19:38 ` mpolacek at gcc dot gnu.org
9 siblings, 0 replies; 13+ messages in thread
From: jsm28 at gcc dot gnu.org @ 2011-04-01 19:36 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36299
--- Comment #12 from Joseph S. Myers <jsm28 at gcc dot gnu.org> 2011-04-01 19:36:27 UTC ---
Author: jsm28
Date: Fri Apr 1 19:36:23 2011
New Revision: 171850
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=171850
Log:
2011-04-01 Vincent Lefevre <vincent+gcc@vinc17.org>
PR c/36299
* gcc.dg/Waddress.c: New test.
Added:
trunk/gcc/testsuite/gcc.dg/Waddress.c
Modified:
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug c/36299] spurious and undocumented warning with -Waddress for a == 0 when a is an array
[not found] <bug-36299-4@http.gcc.gnu.org/bugzilla/>
` (8 preceding siblings ...)
2011-04-01 19:36 ` jsm28 at gcc dot gnu.org
@ 2014-06-30 19:38 ` mpolacek at gcc dot gnu.org
9 siblings, 0 replies; 13+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2014-06-30 19:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=36299
Marek Polacek <mpolacek at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|WAITING |RESOLVED
CC| |mpolacek at gcc dot gnu.org
Resolution|--- |FIXED
--- Comment #13 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
So fixed.
^ permalink raw reply [flat|nested] 13+ messages in thread