public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/81524] Bogus or missing warnings when dereferencing pointer to deallocated stack memory
[not found] <bug-81524-4@http.gcc.gnu.org/bugzilla/>
@ 2022-02-08 23:01 ` msebor at gcc dot gnu.org
2022-02-10 21:29 ` fredrik.hederstierna@securitas-direct.com
2022-02-10 23:35 ` [Bug middle-end/81524] " msebor at gcc dot gnu.org
2 siblings, 0 replies; 3+ messages in thread
From: msebor at gcc dot gnu.org @ 2022-02-08 23:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81524
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |msebor at gcc dot gnu.org
Status|NEW |RESOLVED
Target Milestone|--- |12.0
Resolution|--- |FIXED
Blocks| |104077
--- Comment #6 from Martin Sebor <msebor at gcc dot gnu.org> ---
As far as I can see this works as requested without sanitization in GCC 12:
$ (set -x; for p in PARAM RETURN BLOCK; do for m in READ WRITE; do gcc
-DTEST_${p}_$m -S -Wall pr81524.c; done; done)
+ for p in PARAM RETURN BLOCK
+ for m in READ WRITE
+ gcc -DTEST_PARAM_READ -S -Wall pr81524.c
pr81524.c: In function ‘test_param_local’:
pr81524.c:33:7: warning: storing the address of local variable ‘local’ in ‘*pp’
[-Wdangling-pointer=]
33 | *pp = &local;
| ~~~~^~~~~~~~
pr81524.c:32:7: note: ‘local’ declared here
32 | int local = 1;
| ^~~~~
pr81524.c:32:7: note: ‘pp’ declared here
+ for m in READ WRITE
+ gcc -DTEST_PARAM_WRITE -S -Wall pr81524.c
pr81524.c: In function ‘test_param_local’:
pr81524.c:33:7: warning: storing the address of local variable ‘local’ in ‘*pp’
[-Wdangling-pointer=]
33 | *pp = &local;
| ~~~~^~~~~~~~
pr81524.c:32:7: note: ‘local’ declared here
32 | int local = 1;
| ^~~~~
pr81524.c:32:7: note: ‘pp’ declared here
+ for p in PARAM RETURN BLOCK
+ for m in READ WRITE
+ gcc -DTEST_RETURN_READ -S -Wall pr81524.c
pr81524.c: In function ‘test_return_local’:
pr81524.c:42:10: warning: function returns address of local variable
[-Wreturn-local-addr]
42 | return &local;
| ^~~~~~
+ for m in READ WRITE
+ gcc -DTEST_RETURN_WRITE -S -Wall pr81524.c
pr81524.c: In function ‘test_return_local’:
pr81524.c:42:10: warning: function returns address of local variable
[-Wreturn-local-addr]
42 | return &local;
| ^~~~~~
+ for p in PARAM RETURN BLOCK
+ for m in READ WRITE
+ gcc -DTEST_BLOCK_READ -S -Wall pr81524.c
pr81524.c: In function ‘main’:
pr81524.c:88:10: warning: using dangling pointer ‘p’ to ‘local’
[-Wdangling-pointer=]
88 | return *p;
| ^~
pr81524.c:76:9: note: ‘local’ declared here
76 | int local = 1;
| ^~~~~
pr81524.c:81:3: warning: using dangling pointer ‘p’ to ‘local’
[-Wdangling-pointer=]
81 | printf("%d\n", *p);
| ^~~~~~~~~~~~~~~~~~
pr81524.c:76:9: note: ‘local’ declared here
76 | int local = 1;
| ^~~~~
+ for m in READ WRITE
+ gcc -DTEST_BLOCK_WRITE -S -Wall pr81524.c
pr81524.c: In function ‘main’:
pr81524.c:88:10: warning: using dangling pointer ‘p’ to ‘local’
[-Wdangling-pointer=]
88 | return *p;
| ^~
pr81524.c:76:9: note: ‘local’ declared here
76 | int local = 1;
| ^~~~~
pr81524.c:84:6: warning: using dangling pointer ‘p’ to ‘local’
[-Wdangling-pointer=]
84 | *p = 1;
| ~~~^~~
pr81524.c:76:9: note: ‘local’ declared here
76 | int local = 1;
| ^~~~~
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104077
[Bug 104077] bogus/missing -Wdangling-pointer
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c/81524] Bogus or missing warnings when dereferencing pointer to deallocated stack memory
[not found] <bug-81524-4@http.gcc.gnu.org/bugzilla/>
2022-02-08 23:01 ` [Bug c/81524] Bogus or missing warnings when dereferencing pointer to deallocated stack memory msebor at gcc dot gnu.org
@ 2022-02-10 21:29 ` fredrik.hederstierna@securitas-direct.com
2022-02-10 23:35 ` [Bug middle-end/81524] " msebor at gcc dot gnu.org
2 siblings, 0 replies; 3+ messages in thread
From: fredrik.hederstierna@securitas-direct.com @ 2022-02-10 21:29 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81524
--- Comment #7 from Fredrik Hederstierna <fredrik.hederstierna@securitas-direct.com> ---
I tested GCC-12 and it now correctly warns for these test cases.
Great work, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug middle-end/81524] Bogus or missing warnings when dereferencing pointer to deallocated stack memory
[not found] <bug-81524-4@http.gcc.gnu.org/bugzilla/>
2022-02-08 23:01 ` [Bug c/81524] Bogus or missing warnings when dereferencing pointer to deallocated stack memory msebor at gcc dot gnu.org
2022-02-10 21:29 ` fredrik.hederstierna@securitas-direct.com
@ 2022-02-10 23:35 ` msebor at gcc dot gnu.org
2 siblings, 0 replies; 3+ messages in thread
From: msebor at gcc dot gnu.org @ 2022-02-10 23:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81524
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|c |middle-end
--- Comment #8 from Martin Sebor <msebor at gcc dot gnu.org> ---
Thanks for the confirmation (and for your patience)!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-02-10 23:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <bug-81524-4@http.gcc.gnu.org/bugzilla/>
2022-02-08 23:01 ` [Bug c/81524] Bogus or missing warnings when dereferencing pointer to deallocated stack memory msebor at gcc dot gnu.org
2022-02-10 21:29 ` fredrik.hederstierna@securitas-direct.com
2022-02-10 23:35 ` [Bug middle-end/81524] " msebor 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).