public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/17308] nonnull attribute not as useful as it could
       [not found] <bug-17308-4@http.gcc.gnu.org/bugzilla/>
@ 2011-02-11 17:00 ` ericb at gcc dot gnu.org
  2011-02-11 19:44 ` manu at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: ericb at gcc dot gnu.org @ 2011-02-11 17:00 UTC (permalink / raw)
  To: gcc-bugs

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

Eric Blake <ericb at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ericb at gcc dot gnu.org

--- Comment #6 from Eric Blake <ericb at gcc dot gnu.org> 2011-02-11 16:58:01 UTC ---
It's been several years, and this attribute is still missing functionality
about warning for deduced NULL values.  Can this be looked at?


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

* [Bug middle-end/17308] nonnull attribute not as useful as it could
       [not found] <bug-17308-4@http.gcc.gnu.org/bugzilla/>
  2011-02-11 17:00 ` [Bug middle-end/17308] nonnull attribute not as useful as it could ericb at gcc dot gnu.org
@ 2011-02-11 19:44 ` manu at gcc dot gnu.org
  2012-04-25 19:32 ` ericb at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: manu at gcc dot gnu.org @ 2011-02-11 19:44 UTC (permalink / raw)
  To: gcc-bugs

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

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu.org

--- Comment #7 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2011-02-11 19:43:20 UTC ---
(In reply to comment #6)
> It's been several years, and this attribute is still missing functionality
> about warning for deduced NULL values.  Can this be looked at?

GCC has as a unwritten policy to not emit warnings from the middle-end, except
for a few exceptions. The front-ends do not have the infrastructure to do this
kind of analysis, and GCC maintainers have repeatedly said that there is no
intention to make gcc front-ends serve as a source code analysis tool like the
clang analyzer. So, unless new contributors step forward with a convincing
implementation of this, and for what I mean by "convincing" please read point 3
in the notes to beginners[*], the answer is: No, I wouldn't expect this to be
implemented in the near or medium future. Sorry for the bad news, but I think
it is better to be honest and save you the frustration. 

[*] http://gcc.gnu.org/wiki/GCC_Research


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

* [Bug middle-end/17308] nonnull attribute not as useful as it could
       [not found] <bug-17308-4@http.gcc.gnu.org/bugzilla/>
  2011-02-11 17:00 ` [Bug middle-end/17308] nonnull attribute not as useful as it could ericb at gcc dot gnu.org
  2011-02-11 19:44 ` manu at gcc dot gnu.org
@ 2012-04-25 19:32 ` ericb at gcc dot gnu.org
  2012-04-25 20:04 ` manu at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: ericb at gcc dot gnu.org @ 2012-04-25 19:32 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Eric Blake <ericb at gcc dot gnu.org> 2012-04-25 19:31:59 UTC ---
I hit this again today, and I'm still upset that gcc is doing such a poor job
with (not) using this attribute as a way to improve code quality via decent
warnings.

Basically, libvirt had an issue where we accidentally misused the nonnull
attribute marker; we had added the marker in a header file, then later changed
the C file to work with a NULL argument but without updating the header file to
match: https://bugzilla.redhat.com/show_bug.cgi?id=815270

The calling code managed to pass in a NULL pointer to a parameter based on the
semantics we saw in the .c file, but the NULL check in our function in question
was "helpfully" elided by gcc since the attribute was still present, all
without ever warning us that we were losing the NULL check.  As a result, the
code misbehaved when it dereferenced NULL.  If gcc is smart enough to elide
code based on the attribute, it should be smart enough to issue a warning that
we have dead code, and the only reason the code is assumed to be dead is
because of a suspicious attribute.  Had we had the warning, we would have known
to either remove our dead NULL check, or to fix the header to no longer have
the (now-inappropriate) attribute.

In other words, with a header like:

void foo(void *bar) __attribute__((nonnull(1)));

and a C file like:

void foo(void *bar) { if (!bar) abort(); }

Even if you decide that you are unable to warn about a call to foo(var) because
the only way to analyze that var might be NULL is in the middle end but the
warning is only emitted by the front end, AT LEAST you could have warned that
the 'if (!bar)' conditional is assumed to be dead code based on the attribute
placed on var.


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

* [Bug middle-end/17308] nonnull attribute not as useful as it could
       [not found] <bug-17308-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2012-04-25 19:32 ` ericb at gcc dot gnu.org
@ 2012-04-25 20:04 ` manu at gcc dot gnu.org
  2015-07-25 20:04 ` manu at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: manu at gcc dot gnu.org @ 2012-04-25 20:04 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Manuel López-Ibáñez <manu at gcc dot gnu.org> 2012-04-25 20:00:44 UTC ---
(In reply to comment #8)
> Even if you decide that you are unable to warn about a call to foo(var) because
> the only way to analyze that var might be NULL is in the middle end but the
> warning is only emitted by the front end, AT LEAST you could have warned that
> the 'if (!bar)' conditional is assumed to be dead code based on the attribute
> placed on var.

GCC does not warn about unreachable code anymore:

http://gcc.gnu.org/ml/gcc-help/2011-05/msg00360.html

Someone would have to contribute a new -Wunreachable-code implementation. I
honestly don't know what kind of implementation would be acceptable by GCC
maintainers. Maybe one implemented in the FE? If so, it would require exactly
the same infrastructure necessary to implement what Ulrich asks for above.

Sorry, comment #7 still applies.


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

* [Bug middle-end/17308] nonnull attribute not as useful as it could
       [not found] <bug-17308-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2012-04-25 20:04 ` manu at gcc dot gnu.org
@ 2015-07-25 20:04 ` manu at gcc dot gnu.org
  2015-09-11 21:51 ` mark at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: manu at gcc dot gnu.org @ 2015-07-25 20:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=17308

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |eike@sf-mail.de

--- Comment #10 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
*** Bug 46936 has been marked as a duplicate of this bug. ***
>From gcc-bugs-return-493337-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Jul 25 20:04:16 2015
Return-Path: <gcc-bugs-return-493337-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 58175 invoked by alias); 25 Jul 2015 20:04:16 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 58055 invoked by uid 48); 25 Jul 2015 20:04:12 -0000
From: "manu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/46936] turn __attribute__ ((nonnull (x))) into assert in debug mode
Date: Sat, 25 Jul 2015 20:04:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c
X-Bugzilla-Version: unknown
X-Bugzilla-Keywords:
X-Bugzilla-Severity: enhancement
X-Bugzilla-Who: manu at gcc dot gnu.org
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Resolution: DUPLICATE
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cc resolution
Message-ID: <bug-46936-4-PGdjMp1zT5@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-46936-4@http.gcc.gnu.org/bugzilla/>
References: <bug-46936-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-07/txt/msg02227.txt.bz2
Content-length: 717

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46936

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|                            |manu at gcc dot gnu.org
         Resolution|---                         |DUPLICATE

--- Comment #5 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
I think -fsanitize should already detect this at run time, but GCC could indeed
warn for those cases that it detects.

*** This bug has been marked as a duplicate of bug 17308 ***
>From gcc-bugs-return-493339-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Jul 25 20:05:28 2015
Return-Path: <gcc-bugs-return-493339-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 69189 invoked by alias); 25 Jul 2015 20:05:28 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 65325 invoked by uid 48); 25 Jul 2015 20:05:24 -0000
From: "manu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/44081] Incorrect nonnull assumed in code generation
Date: Sat, 25 Jul 2015 20:05:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: middle-end
X-Bugzilla-Version: 4.5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: manu at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cc
Message-ID: <bug-44081-4-GpIjuPXwCm@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-44081-4@http.gcc.gnu.org/bugzilla/>
References: <bug-44081-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-07/txt/msg02229.txt.bz2
Content-length: 441

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44081

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |manu at gcc dot gnu.org

--- Comment #13 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
Should we close this?
>From gcc-bugs-return-493340-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Jul 25 20:12:35 2015
Return-Path: <gcc-bugs-return-493340-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 74174 invoked by alias); 25 Jul 2015 20:12:35 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 74120 invoked by uid 48); 25 Jul 2015 20:12:31 -0000
From: "manu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/64463] Add warning: returns_nonnull attribute on a function compared against NULL
Date: Sat, 25 Jul 2015 20:12:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: middle-end
X-Bugzilla-Version: 4.9.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: manu at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on cc blocked everconfirmed
Message-ID: <bug-64463-4-L3fnag8bgL@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-64463-4@http.gcc.gnu.org/bugzilla/>
References: <bug-64463-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-07/txt/msg02230.txt.bz2
Content-length: 827

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64463

Manuel López-Ibáñez <manu at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-07-25
                 CC|                            |manu at gcc dot gnu.org
             Blocks|                            |58689
     Ever confirmed|0                           |1

--- Comment #1 from Manuel López-Ibáñez <manu at gcc dot gnu.org> ---
Confirmed. Related to PR17308. This is one of the things requested in PR58689.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58689
[Bug 58689] Enhance returns_nonnull
>From gcc-bugs-return-493341-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Jul 25 20:39:31 2015
Return-Path: <gcc-bugs-return-493341-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 126430 invoked by alias); 25 Jul 2015 20:39:31 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 126217 invoked by uid 48); 25 Jul 2015 20:39:27 -0000
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/66996] [6 Regression] defined but not used [-Wunused-function]
Date: Sat, 25 Jul 2015 20:39:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 6.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: pinskia at gcc dot gnu.org
X-Bugzilla-Status: NEW
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 6.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-66996-4-lr0wwW7oKm@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-66996-4@http.gcc.gnu.org/bugzilla/>
References: <bug-66996-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-07/txt/msg02231.txt.bz2
Content-length: 241

https://gcc.gnu.org/bugzilla/show_bug.cgi?idf996

--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The warning seems correct as Foo::~Foo is not used and the function can be used
outside of the current translation unit.


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

* [Bug middle-end/17308] nonnull attribute not as useful as it could
       [not found] <bug-17308-4@http.gcc.gnu.org/bugzilla/>
                   ` (4 preceding siblings ...)
  2015-07-25 20:04 ` manu at gcc dot gnu.org
@ 2015-09-11 21:51 ` mark at gcc dot gnu.org
  2023-02-02 22:39 ` [Bug middle-end/17308] nonnull attribute not as useful as it could be pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: mark at gcc dot gnu.org @ 2015-09-11 21:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=17308

Mark Wielaard <mark at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mark at gcc dot gnu.org

--- Comment #11 from Mark Wielaard <mark at gcc dot gnu.org> ---
(In reply to Eric Blake from comment #8)
> In other words, with a header like:
> 
> void foo(void *bar) __attribute__((nonnull(1)));
> 
> and a C file like:
> 
> void foo(void *bar) { if (!bar) abort(); }
> 
> Even if you decide that you are unable to warn about a call to foo(var)
> because the only way to analyze that var might be NULL is in the middle end
> but the warning is only emitted by the front end, AT LEAST you could have
> warned that the 'if (!bar)' conditional is assumed to be dead code based on
> the attribute placed on var.

This part has now been implemented:
https://gcc.gnu.org/ml/gcc-patches/2015-09/msg00626.html


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

* [Bug middle-end/17308] nonnull attribute not as useful as it could be
       [not found] <bug-17308-4@http.gcc.gnu.org/bugzilla/>
                   ` (5 preceding siblings ...)
  2015-09-11 21:51 ` mark at gcc dot gnu.org
@ 2023-02-02 22:39 ` pinskia at gcc dot gnu.org
  2023-02-02 22:39 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-02-02 22:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=17308

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|FIXED                       |---
             Status|RESOLVED                    |NEW

--- Comment #21 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The patch was reverted, see PR 78817 on the reasons why.

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

* [Bug middle-end/17308] nonnull attribute not as useful as it could be
       [not found] <bug-17308-4@http.gcc.gnu.org/bugzilla/>
                   ` (6 preceding siblings ...)
  2023-02-02 22:39 ` [Bug middle-end/17308] nonnull attribute not as useful as it could be pinskia at gcc dot gnu.org
@ 2023-02-02 22:39 ` pinskia at gcc dot gnu.org
  2023-02-02 22:43 ` pinskia at gcc dot gnu.org
  2023-02-03  1:19 ` segher at gcc dot gnu.org
  9 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-02-02 22:39 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=17308

--- Comment #22 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 95515 has been marked as a duplicate of this bug. ***

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

* [Bug middle-end/17308] nonnull attribute not as useful as it could be
       [not found] <bug-17308-4@http.gcc.gnu.org/bugzilla/>
                   ` (7 preceding siblings ...)
  2023-02-02 22:39 ` pinskia at gcc dot gnu.org
@ 2023-02-02 22:43 ` pinskia at gcc dot gnu.org
  2023-02-03  1:19 ` segher at gcc dot gnu.org
  9 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-02-02 22:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=17308

--- Comment #23 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The patch which would have "fixed" this was reverted as there was too many
false positives and that happens when you do optimization based warnings ...
I don't know if we want to keep this open or close this as won't fix though. 
It has been 6 years since this was tried too and we still most likely have just
as many false positives as before even.
I also suspect many of these new warnings we are doing in recent years really
should not be part of -Wall because of how many false positives we have. GCC
has been getting a recent attention because of the false positives warnings
too.

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

* [Bug middle-end/17308] nonnull attribute not as useful as it could be
       [not found] <bug-17308-4@http.gcc.gnu.org/bugzilla/>
                   ` (8 preceding siblings ...)
  2023-02-02 22:43 ` pinskia at gcc dot gnu.org
@ 2023-02-03  1:19 ` segher at gcc dot gnu.org
  9 siblings, 0 replies; 17+ messages in thread
From: segher at gcc dot gnu.org @ 2023-02-03  1:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=17308

--- Comment #24 from Segher Boessenkool <segher at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #23)
> I also suspect many of these new warnings we are doing in recent years
> really should not be part of -Wall because of how many false positives we
> have. GCC has been getting a recent attention because of the false positives
> warnings too.

Current documentation says

'-Wall'
     This enables all the warnings about constructions that some users
     consider questionable, and that are easy to avoid (or modify to
     prevent the warning), even in conjunction with macros.

and

'-Wextra'
     This enables some extra warning flags that are not enabled by
     '-Wall'.

We don't document at all what options should be enabled by -Wall, what
options should be enabled by -W, and which should be done by neither.  The
current documentation for -Wall is very noncommittal.

It all is a tradeoff of course.  IMO our documentation should make that clear
as well.

In my view, -Wall should enable all warnings that have few false positives
(less than 5% or 10%, say), and when they do this is easy to avoid, or perhaps
the warning points out very important (security) problems.

-W is the same but with higher tolerance for false positives.  And the
warnings that are not so useful, or are hard to avoid, and have a high false
positive rate, should not be enabled by either.

(Oh, and please note that -Werror is not part of these considerations at all.
When -Werror makes things "break" this is just a learning opportunity for
whoever asked for it.  Maybe we should document -Werror as an alias of
-Wself-flagellation).

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

* [Bug middle-end/17308] nonnull attribute not as useful as it could
       [not found] <bug-17308-700@http.gcc.gnu.org/bugzilla/>
  2008-04-25 20:53 ` [Bug middle-end/17308] nonnull attribute not as useful as it could pinskia at gcc dot gnu dot org
  2008-12-23 15:42 ` thutt at vmware dot com
@ 2010-02-15 20:51 ` msebor at gmail dot com
  2 siblings, 0 replies; 17+ messages in thread
From: msebor at gmail dot com @ 2010-02-15 20:51 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from msebor at gmail dot com  2010-02-15 20:51 -------
I second Ulrich's request.

Besides nonnull, this enhancement would be useful in attribute printf
as well. For example, in the program below, both calls to printf() have
undefined behavior in C99 and should be diagnosed:

$ cat t.c && gcc -Wformat -pedantic -std=c99 -O3 t.c
int printf(const char*, ...)
  __attribute__((__nonnull__((1))))
  __attribute__ ((__format__ (__printf__, 1, 2)));

int main() {
  char *s = 0;
  printf(s, "");
  printf("%s", s);
}
$


-- 

msebor at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gmail dot com


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


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

* [Bug middle-end/17308] nonnull attribute not as useful as it could
       [not found] <bug-17308-700@http.gcc.gnu.org/bugzilla/>
  2008-04-25 20:53 ` [Bug middle-end/17308] nonnull attribute not as useful as it could pinskia at gcc dot gnu dot org
@ 2008-12-23 15:42 ` thutt at vmware dot com
  2010-02-15 20:51 ` msebor at gmail dot com
  2 siblings, 0 replies; 17+ messages in thread
From: thutt at vmware dot com @ 2008-12-23 15:42 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 3437 bytes --]



------- Comment #4 from thutt at vmware dot com  2008-12-23 15:40 -------
/*
  I concur with Ulrich, but three years on, using gcc 4.1.2.

  Although a parameter which is marked with the 'nonnull' attribute
  is demonstrably nonnull, and although the compiler recognizes it is
  specifically NULL, no warning is emitted.

  And, in fact, the compiler can end up generating bad code.

  Using built-in specs.
  Target: x86_64-redhat-linux
  Configured with: ../configure --prefix=/usr --mandir=/usr/share/man  \
    --infodir=/usr/share/info --enable-shared --enable-threads=posix   \
    --enable-checking=release --with-system-zlib --enable-__cxa_atexit \
    --disable-libunwind-exceptions --enable-libgcj-multifile           \
    --enable-languages=c,c++,objc,obj-c++,java,fortran,ada             \
    --enable-java-awt=gtk --disable-dssi --enable-plugin               \
    --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre           \
    --with-cpu=generic --host=x86_64-redhat-linux
  Thread model: posix
  gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)



        gcc -c  -o nonnull.o -O3 -Wall nonnull.c
        nonnull.c: In function ‘f1’:
        nonnull.c:52: warning: null argument where non-null required (argument
1)
        nonnull.c:52: warning: null argument where non-null required (argument
2)

        objdump --disassemble --reloc nonnull.o

        nonnull.o:     file format elf64-x86-64

        Disassembly of section .text:

        0000000000000000 <f1>:
           0:   f3 c3                   repz retq
           2:   0f 1f 80 00 00 00 00    nopl   0x0(%rax)
           9:   0f 1f 80 00 00 00 00    nopl   0x0(%rax)

  If '-Wall' is not provided, the compiler does not even warn about
  the NULL arguments.  It hardly matters if the compiler warns or not,
  the code that is generated for 'f1()' is simply bad code.  But, when
  no warning is provided by the compiler, the code is egregiously bad
  -- anyone wondering why their program doesn't work may disassemble
  the object module and see that nothing was emitted.

        0000000000000010 <f0>:
          10:   ba 00 04 00 00          mov    $0x400,%edx     ; length = 1024
          15:   31 f6                   xor    %esi,%esi       ; second arg =
NULL
          17:   bf 00 00 00 00          mov    $0x0,%edi       ; first arg =
buf
          1c:   48 c7 05 00 00 00 00    movq   $0x0,0(%rip)    ; a = buf
          23:   00 00 00 00
          27:   48 c7 05 00 00 00 00    movq   $0x0,0(%rip)    ; b = NULL
          2e:   00 00 00 00
          32:   e9 00 00 00 00          jmpq   memcpy

  In this function, the compiler has automatically inlined
  'copy_block()', and obviously determined that the second parameter
  is NULL, as can be seen from addresses 15 & 27 -- but still no
  warning is presented.
 */

#include <stdlib.h>
#include <string.h>

extern void *a;
extern void *b;

static void __attribute__((nonnull(1, 2)))
copy_block(void *dest, void *src)
{
   memcpy(dest, src, 1024);
}


void f0(void)
{
   static char buf[100];
   a = buf;
   b = NULL;
   copy_block(a, b);
}

void f1(void)
{
   copy_block(NULL, NULL);
}


-- 

thutt at vmware dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |thutt at vmware dot com


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


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

* [Bug middle-end/17308] nonnull attribute not as useful as it could
       [not found] <bug-17308-700@http.gcc.gnu.org/bugzilla/>
@ 2008-04-25 20:53 ` pinskia at gcc dot gnu dot org
  2008-12-23 15:42 ` thutt at vmware dot com
  2010-02-15 20:51 ` msebor at gmail dot com
  2 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-04-25 20:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2008-04-25 20:52 -------
*** Bug 30043 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |madcoder at debian dot org


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


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

* [Bug middle-end/17308] nonnull attribute not as useful as it could
  2004-09-03 20:03 [Bug middle-end/17308] New: " drepper at redhat dot com
                   ` (2 preceding siblings ...)
  2004-12-09  0:17 ` pinskia at gcc dot gnu dot org
@ 2005-06-24 23:13 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-06-24 23:13 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-06-24 23:13 -------
*** Bug 22179 has been marked as a duplicate of this bug. ***

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jesse dot millan at gmail
                   |                            |dot com


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


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

* [Bug middle-end/17308] nonnull attribute not as useful as it could
  2004-09-03 20:03 [Bug middle-end/17308] New: " drepper at redhat dot com
  2004-09-03 20:10 ` [Bug middle-end/17308] " pinskia at gcc dot gnu dot org
  2004-09-09  3:42 ` pinskia at gcc dot gnu dot org
@ 2004-12-09  0:17 ` pinskia at gcc dot gnu dot org
  2005-06-24 23:13 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-12-09  0:17 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic
   Last reconfirmed|2004-09-09 03:42:31         |2004-12-09 00:17:09
               date|                            |


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


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

* [Bug middle-end/17308] nonnull attribute not as useful as it could
  2004-09-03 20:03 [Bug middle-end/17308] New: " drepper at redhat dot com
  2004-09-03 20:10 ` [Bug middle-end/17308] " pinskia at gcc dot gnu dot org
@ 2004-09-09  3:42 ` pinskia at gcc dot gnu dot org
  2004-12-09  0:17 ` pinskia at gcc dot gnu dot org
  2005-06-24 23:13 ` pinskia at gcc dot gnu dot org
  3 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-09  3:42 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-09-09 03:42:31
               date|                            |


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


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

* [Bug middle-end/17308] nonnull attribute not as useful as it could
  2004-09-03 20:03 [Bug middle-end/17308] New: " drepper at redhat dot com
@ 2004-09-03 20:10 ` pinskia at gcc dot gnu dot org
  2004-09-09  3:42 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 17+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-09-03 20:10 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-09-03 20:10 -------
I think the issue here is that we issue the warning way before getting to the middle-end, in the front-
end.

-- 


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


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

end of thread, other threads:[~2023-02-03  1:19 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-17308-4@http.gcc.gnu.org/bugzilla/>
2011-02-11 17:00 ` [Bug middle-end/17308] nonnull attribute not as useful as it could ericb at gcc dot gnu.org
2011-02-11 19:44 ` manu at gcc dot gnu.org
2012-04-25 19:32 ` ericb at gcc dot gnu.org
2012-04-25 20:04 ` manu at gcc dot gnu.org
2015-07-25 20:04 ` manu at gcc dot gnu.org
2015-09-11 21:51 ` mark at gcc dot gnu.org
2023-02-02 22:39 ` [Bug middle-end/17308] nonnull attribute not as useful as it could be pinskia at gcc dot gnu.org
2023-02-02 22:39 ` pinskia at gcc dot gnu.org
2023-02-02 22:43 ` pinskia at gcc dot gnu.org
2023-02-03  1:19 ` segher at gcc dot gnu.org
     [not found] <bug-17308-700@http.gcc.gnu.org/bugzilla/>
2008-04-25 20:53 ` [Bug middle-end/17308] nonnull attribute not as useful as it could pinskia at gcc dot gnu dot org
2008-12-23 15:42 ` thutt at vmware dot com
2010-02-15 20:51 ` msebor at gmail dot com
2004-09-03 20:03 [Bug middle-end/17308] New: " drepper at redhat dot com
2004-09-03 20:10 ` [Bug middle-end/17308] " pinskia at gcc dot gnu dot org
2004-09-09  3:42 ` pinskia at gcc dot gnu dot org
2004-12-09  0:17 ` pinskia at gcc dot gnu dot org
2005-06-24 23:13 ` 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).