public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c/20318] RFE: add attribute to specify that a function never returns NULL [not found] <bug-20318-10211@http.gcc.gnu.org/bugzilla/> @ 2005-11-11 23:29 ` green at redhat dot com 2005-11-12 19:26 ` pinskia at gcc dot gnu dot org 2006-01-09 18:34 ` pinskia at gcc dot gnu dot org 2 siblings, 0 replies; 10+ messages in thread From: green at redhat dot com @ 2005-11-11 23:29 UTC (permalink / raw) To: gcc-bugs ------- Comment #7 from green at redhat dot com 2005-11-11 23:29 ------- This feature would also be useful for java, as we can eliminate certain inlined null pointer checks when we know that a method can't return null. See http://gcc.gnu.org/ml/java/2005-11/msg00124.html -- green at redhat dot com changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |green at redhat dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20318 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c/20318] RFE: add attribute to specify that a function never returns NULL [not found] <bug-20318-10211@http.gcc.gnu.org/bugzilla/> 2005-11-11 23:29 ` [Bug c/20318] RFE: add attribute to specify that a function never returns NULL green at redhat dot com @ 2005-11-12 19:26 ` pinskia at gcc dot gnu dot org 2006-01-09 18:34 ` pinskia at gcc dot gnu dot org 2 siblings, 0 replies; 10+ messages in thread From: pinskia at gcc dot gnu dot org @ 2005-11-12 19:26 UTC (permalink / raw) To: gcc-bugs ------- Comment #8 from pinskia at gcc dot gnu dot org 2005-11-12 19:26 ------- I have a patch already. -- pinskia at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|dnovillo at gcc dot gnu dot |pinskia at gcc dot gnu dot |org |org Status|NEW |ASSIGNED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20318 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c/20318] RFE: add attribute to specify that a function never returns NULL [not found] <bug-20318-10211@http.gcc.gnu.org/bugzilla/> 2005-11-11 23:29 ` [Bug c/20318] RFE: add attribute to specify that a function never returns NULL green at redhat dot com 2005-11-12 19:26 ` pinskia at gcc dot gnu dot org @ 2006-01-09 18:34 ` pinskia at gcc dot gnu dot org 2 siblings, 0 replies; 10+ messages in thread From: pinskia at gcc dot gnu dot org @ 2006-01-09 18:34 UTC (permalink / raw) To: gcc-bugs ------- Comment #9 from pinskia at gcc dot gnu dot org 2006-01-09 18:34 ------- No longer working on this, I am too busy working on the gfortran front-end. -- pinskia at gcc dot gnu dot org changed: What |Removed |Added ---------------------------------------------------------------------------- AssignedTo|pinskia at gcc dot gnu dot |unassigned at gcc dot gnu |org |dot org Status|ASSIGNED |NEW http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20318 ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <bug-20318-4@http.gcc.gnu.org/bugzilla/>]
* [Bug c/20318] RFE: add attribute to specify that a function never returns NULL [not found] <bug-20318-4@http.gcc.gnu.org/bugzilla/> @ 2013-10-09 13:03 ` glisse at gcc dot gnu.org 2013-10-11 11:48 ` glisse at gcc dot gnu.org 1 sibling, 0 replies; 10+ messages in thread From: glisse at gcc dot gnu.org @ 2013-10-09 13:03 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20318 --- Comment #10 from Marc Glisse <glisse at gcc dot gnu.org> --- Author: glisse Date: Wed Oct 9 13:03:13 2013 New Revision: 203316 URL: http://gcc.gnu.org/viewcvs?rev=203316&root=gcc&view=rev Log: 2013-10-09 Marc Glisse <marc.glisse@inria.fr> PR tree-optimization/20318 gcc/c-family/ * c-common.c (handle_returns_nonnull_attribute): New function. (c_common_attribute_table): Add returns_nonnull. gcc/ * doc/extend.texi (returns_nonnull): New function attribute. * fold-const.c (tree_expr_nonzero_warnv_p): Look for returns_nonnull attribute. * tree-vrp.c (gimple_stmt_nonzero_warnv_p): Likewise. (stmt_interesting_for_vrp): Accept all GIMPLE_CALL. gcc/testsuite/ * c-c++-common/pr20318.c: New file. * gcc.dg/tree-ssa/pr20318.c: New file. Added: trunk/gcc/testsuite/c-c++-common/pr20318.c (with props) trunk/gcc/testsuite/gcc.dg/tree-ssa/pr20318.c (with props) Modified: trunk/gcc/ChangeLog trunk/gcc/c-family/ChangeLog trunk/gcc/c-family/c-common.c trunk/gcc/doc/extend.texi trunk/gcc/fold-const.c trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-vrp.c Propchange: trunk/gcc/testsuite/c-c++-common/pr20318.c ('svn:eol-style' added) Propchange: trunk/gcc/testsuite/c-c++-common/pr20318.c ('svn:keywords' added) Propchange: trunk/gcc/testsuite/gcc.dg/tree-ssa/pr20318.c ('svn:eol-style' added) Propchange: trunk/gcc/testsuite/gcc.dg/tree-ssa/pr20318.c ('svn:keywords' added) ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c/20318] RFE: add attribute to specify that a function never returns NULL [not found] <bug-20318-4@http.gcc.gnu.org/bugzilla/> 2013-10-09 13:03 ` glisse at gcc dot gnu.org @ 2013-10-11 11:48 ` glisse at gcc dot gnu.org 1 sibling, 0 replies; 10+ messages in thread From: glisse at gcc dot gnu.org @ 2013-10-11 11:48 UTC (permalink / raw) To: gcc-bugs http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20318 Marc Glisse <glisse at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED CC| |glisse at gcc dot gnu.org Resolution|--- |FIXED --- Comment #11 from Marc Glisse <glisse at gcc dot gnu.org> --- Marking svn_fs_fs__id_parse and svn_error_create with the new __attribute__((__returns_nonnull__)) makes the warning about root_id disappear at -O3, so I am going to mark this bug as fixed, please reopen if necessary. ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c/20318] New: RFE: add attribute to specify that a function never returns NULL @ 2005-03-04 15:32 jorton at redhat dot com 2005-03-04 15:38 ` [Bug c/20318] " pinskia at gcc dot gnu dot org ` (4 more replies) 0 siblings, 5 replies; 10+ messages in thread From: jorton at redhat dot com @ 2005-03-04 15:32 UTC (permalink / raw) To: gcc-bugs It would be useful to have a function attribute which specifies that the function never returns NULL. Currently the GCC 4 snapshots with -O2 -Wall generate ~15 spurious warnings in the Subversion source code which could be eliminated if a couple of functions could be marked as never returning NULL. -- Summary: RFE: add attribute to specify that a function never returns NULL Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: enhancement Priority: P2 Component: c AssignedTo: dnovillo at gcc dot gnu dot org ReportedBy: jorton at redhat dot com CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20318 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c/20318] RFE: add attribute to specify that a function never returns NULL 2005-03-04 15:32 [Bug c/20318] New: " jorton at redhat dot com @ 2005-03-04 15:38 ` pinskia at gcc dot gnu dot org 2005-03-04 17:53 ` giovannibajo at libero dot it ` (3 subsequent siblings) 4 siblings, 0 replies; 10+ messages in thread From: pinskia at gcc dot gnu dot org @ 2005-03-04 15:38 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From pinskia at gcc dot gnu dot org 2005-03-04 15:38 ------- Confirmed, PR 19476 is case which depends on this. -- What |Removed |Added ---------------------------------------------------------------------------- CC| |pinskia at gcc dot gnu dot | |org OtherBugsDependingO| |19476 nThis| | Status|UNCONFIRMED |NEW Ever Confirmed| |1 Keywords| |diagnostic, missed- | |optimization Last reconfirmed|0000-00-00 00:00:00 |2005-03-04 15:38:22 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20318 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c/20318] RFE: add attribute to specify that a function never returns NULL 2005-03-04 15:32 [Bug c/20318] New: " jorton at redhat dot com 2005-03-04 15:38 ` [Bug c/20318] " pinskia at gcc dot gnu dot org @ 2005-03-04 17:53 ` giovannibajo at libero dot it 2005-03-04 17:59 ` dnovillo at redhat dot com ` (2 subsequent siblings) 4 siblings, 0 replies; 10+ messages in thread From: giovannibajo at libero dot it @ 2005-03-04 17:53 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From giovannibajo at libero dot it 2005-03-04 17:53 ------- I don't object that this feature is indeed needed, but I would still like to see a reduced testcase from Subversion which shows a bogus warning that could be fixed with this attribute. BTW, Diego, once ASSERT_EXPR becomes a generic node, can't just the C++ FE uses it to assert that the return value for a CALL_EXPR to an allocation function is non-zero? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20318 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c/20318] RFE: add attribute to specify that a function never returns NULL 2005-03-04 15:32 [Bug c/20318] New: " jorton at redhat dot com 2005-03-04 15:38 ` [Bug c/20318] " pinskia at gcc dot gnu dot org 2005-03-04 17:53 ` giovannibajo at libero dot it @ 2005-03-04 17:59 ` dnovillo at redhat dot com 2005-03-04 18:01 ` dnovillo at gcc dot gnu dot org 2005-06-03 14:20 ` pinskia at gcc dot gnu dot org 4 siblings, 0 replies; 10+ messages in thread From: dnovillo at redhat dot com @ 2005-03-04 17:59 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From dnovillo at redhat dot com 2005-03-04 17:59 ------- Subject: Re: RFE: add attribute to specify that a function never returns NULL giovannibajo at libero dot it wrote: > ------- Additional Comments From giovannibajo at libero dot it 2005-03-04 17:53 ------- > I don't object that this feature is indeed needed, but I would still like to > see a reduced testcase from Subversion which shows a bogus warning that could > be fixed with this attribute. > I have attached the pre-processed test case from Joe. > BTW, Diego, once ASSERT_EXPR becomes a generic node, can't just the C++ FE uses > it to assert that the return value for a CALL_EXPR to an allocation function is > non-zero? > The attribute would be enough. The FE need only set an ECF_ flag to the CALL_EXPR and the optimizers will pick it up from there. Diego. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20318 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c/20318] RFE: add attribute to specify that a function never returns NULL 2005-03-04 15:32 [Bug c/20318] New: " jorton at redhat dot com ` (2 preceding siblings ...) 2005-03-04 17:59 ` dnovillo at redhat dot com @ 2005-03-04 18:01 ` dnovillo at gcc dot gnu dot org 2005-06-03 14:20 ` pinskia at gcc dot gnu dot org 4 siblings, 0 replies; 10+ messages in thread From: dnovillo at gcc dot gnu dot org @ 2005-03-04 18:01 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From dnovillo at gcc dot gnu dot org 2005-03-04 18:01 ------- Adding some of the early analysis that went on in private mail. > So is there an __attribute__ that we can use to mark that function to > always return non-NULL, so the compiler knows that path is not possible? > No. There is __attribute__ ((noreturn)), but the compiler has no way of knowing that svn_fs_fs__id_parse is guaranteed to return non-NULL. This is what the compiler sees in the IL: root_id_41 = svn_fs_fs__id_parse (node_id_str_39, D.10885_40, pool_5); if (root_id_41 == 0B) goto <L13>; else goto <L17>; <L13>:; svn_error__locate (...); D.10887_45 = dgettext (...); svn_err__temp_46 = svn_error_create (160004, 0B, D.10887_45); # root_id_257 = PHI <root_id_28(10), root_id_41(8)>; <L17>:; [ ... ] <L19>:; *root_id_p_30 = root_id_257; At L19, it sees two possible values for root_id (root_id_28 and root_id_41). root_id_28 is the uninitialized value. We don't have a "can't return NULL" attribute. Though it would be useful. In this case, you're better off initializing *root_id_p at the start of the function. Diego. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20318 ^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c/20318] RFE: add attribute to specify that a function never returns NULL 2005-03-04 15:32 [Bug c/20318] New: " jorton at redhat dot com ` (3 preceding siblings ...) 2005-03-04 18:01 ` dnovillo at gcc dot gnu dot org @ 2005-06-03 14:20 ` pinskia at gcc dot gnu dot org 4 siblings, 0 replies; 10+ messages in thread From: pinskia at gcc dot gnu dot org @ 2005-06-03 14:20 UTC (permalink / raw) To: gcc-bugs ------- Additional Comments From pinskia at gcc dot gnu dot org 2005-06-03 14:20 ------- Here is a reduced testcase for the SVN code: void *g(); static void *count_and_verify_instructions(int *ninst,const unsigned char *p) { if (p == ((void *)0)) return g(); *ninst = 0; return 0; } void f(int); void *decode_window(const unsigned char *data) { int ninst; void *svn_err__temp = count_and_verify_instructions(&ninst, data); if (svn_err__temp) return svn_err__temp; f (ninst); return 0; } ----- cut --------- g returns only non null values. This reduced testcase comes from PR 21320 which comes from OLH. -- What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed|2005-03-04 15:38:22 |2005-06-03 14:20:19 date| | http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20318 ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2013-10-11 11:48 UTC | newest] Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <bug-20318-10211@http.gcc.gnu.org/bugzilla/> 2005-11-11 23:29 ` [Bug c/20318] RFE: add attribute to specify that a function never returns NULL green at redhat dot com 2005-11-12 19:26 ` pinskia at gcc dot gnu dot org 2006-01-09 18:34 ` pinskia at gcc dot gnu dot org [not found] <bug-20318-4@http.gcc.gnu.org/bugzilla/> 2013-10-09 13:03 ` glisse at gcc dot gnu.org 2013-10-11 11:48 ` glisse at gcc dot gnu.org 2005-03-04 15:32 [Bug c/20318] New: " jorton at redhat dot com 2005-03-04 15:38 ` [Bug c/20318] " pinskia at gcc dot gnu dot org 2005-03-04 17:53 ` giovannibajo at libero dot it 2005-03-04 17:59 ` dnovillo at redhat dot com 2005-03-04 18:01 ` dnovillo at gcc dot gnu dot org 2005-06-03 14:20 ` 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).