public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/105346] New: -Wno-free-nonheap-object false positive (on Bison-generated grammar code)
@ 2022-04-22 12:12 tim.vanholder at anubex dot com
  2022-04-22 12:21 ` [Bug c/105346] " rguenth at gcc dot gnu.org
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: tim.vanholder at anubex dot com @ 2022-04-22 12:12 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 105346
           Summary: -Wno-free-nonheap-object false positive (on
                    Bison-generated grammar code)
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tim.vanholder at anubex dot com
  Target Milestone: ---

Bison grammars (can) include code like

    /* The state stack: array, bottom, top.  */
    yy_state_t yyssa[YYINITDEPTH];
    yy_state_t *yyss = yyssa;
    yy_state_t *yyssp = yyss;

... (code that may allocate a larger stack if needed, in which case `yyss` and
`yyssp` get repointed)


  #ifndef yyoverflow
    if (yyss != yyssa)
      YYSTACK_FREE (yyss);
  #endif

(with YYSTACK_FREE() expanding to free()).

For this gcc (Debian 11.2.0-19) 11.2.0 is reporting (with -Werror):

Linux/DML-grammar.cc:13901:18: error: ‘void free(void*)’ called on unallocated
object ‘yyssa’ [-Werror=free-nonheap-object]
13901 |     YYSTACK_FREE (yyss);
Linux/DML-grammar.cc:5609:16: note: declared here
 5609 |     yy_state_t yyssa[YYINITDEPTH];
      |                ^~~~~

So it is tracing yyss to yyssa from its declaration, but is apparently not
seeing that there is an explicit test that yyss is not equal to yyssa around
the free.

(I'd test with a more recent version, but this is what I have available.)

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

end of thread, other threads:[~2023-05-29 10:06 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-22 12:12 [Bug c/105346] New: -Wno-free-nonheap-object false positive (on Bison-generated grammar code) tim.vanholder at anubex dot com
2022-04-22 12:21 ` [Bug c/105346] " rguenth at gcc dot gnu.org
2022-04-26  8:10 ` tim.vanholder at anubex dot com
2022-04-26  9:20 ` tim.vanholder at anubex dot com
2022-04-26  9:21 ` [Bug c++/105346] " tim.vanholder at anubex dot com
2022-04-26  9:40 ` rguenth at gcc dot gnu.org
2022-04-26  9:52 ` [Bug middle-end/105346] " rguenth at gcc dot gnu.org
2022-04-26  9:53 ` [Bug middle-end/105346] [11/12 Regression] " rguenth at gcc dot gnu.org
2022-04-26  9:56 ` jakub at gcc dot gnu.org
2022-04-26 10:09 ` rguenther at suse dot de
2022-04-26 10:12 ` jakub at gcc dot gnu.org
2022-04-26 13:53 ` amacleod at redhat dot com
2022-04-26 14:12 ` aldyh at gcc dot gnu.org
2022-04-27  7:15 ` rguenth at gcc dot gnu.org
2022-04-27  9:06 ` aldyh at gcc dot gnu.org
2022-04-27  9:16 ` rguenth at gcc dot gnu.org
2022-04-27  9:23 ` aldyh at gcc dot gnu.org
2022-04-27 10:17 ` rguenth at gcc dot gnu.org
2023-05-29 10:06 ` [Bug middle-end/105346] [11/12/13/14 " jakub at gcc dot gnu.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).