public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/102539] New: [11/12 regression] -Wmaybe-uninitialized false positive, invalid <unknown> location
@ 2021-09-30 8:23 slyfox at gcc dot gnu.org
2021-09-30 8:24 ` [Bug c/102539] " slyfox at gcc dot gnu.org
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: slyfox at gcc dot gnu.org @ 2021-09-30 8:23 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102539
Bug ID: 102539
Summary: [11/12 regression] -Wmaybe-uninitialized false
positive, invalid <unknown> location
Product: gcc
Version: 11.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: slyfox at gcc dot gnu.org
Target Milestone: ---
Minimal example is extracted from aerospike-server-4.2.0.4:
$ cat a.c.c
void msg_set_buf(const int *);
void clustering_hb_event_listener_buffer_size(void) {
unsigned long succession_buffer = (unsigned long)__builtin_alloca(42);
msg_set_buf((const int*)succession_buffer);
}
$ LANG=C /nix/store/...-gcc-wrapper-12.0.0/bin/gcc -fno-strict-aliasing -Wall
-std=gnu99 -o a.o -c a.c.c -O2
a.c.c: In function 'clustering_hb_event_listener_buffer_size':
a.c.c:4:3: warning: '<unknown>' may be used uninitialized
[-Wmaybe-uninitialized]
4 | msg_set_buf((const int*)succession_buffer);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.c.c:1:6: note: by argument 1 of type 'const int *' to 'msg_set_buf' declared
here
1 | void msg_set_buf(const int *);
| ^~~~~~~~~~~
There are two issues here (both are probably related):
1. '<unknown>' location is reported instead of some form of 'succession_buffer'
reference
2. there should be no warning about uninitialized data, it's the same pointer
passed around
$ LANG=C /nix/store/...-gcc-wrapper-12.0.0/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/nix/store/...-gcc-12.0.0/bin/gcc
COLLECT_LTO_WRAPPER=/nix/store/...-gcc-12.0.0/libexec/gcc/x86_64-unknown-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with:
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210919 (experimental) (GCC)
Affected compilers:
- 12.0.0 20210919 snapshot
- 11.1.0 release
Unaffected compilers:
- 10.3.0 release
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug c/102539] [11/12 regression] -Wmaybe-uninitialized false positive, invalid <unknown> location
2021-09-30 8:23 [Bug c/102539] New: [11/12 regression] -Wmaybe-uninitialized false positive, invalid <unknown> location slyfox at gcc dot gnu.org
@ 2021-09-30 8:24 ` slyfox at gcc dot gnu.org
2021-09-30 8:32 ` [Bug tree-optimization/102539] " pinskia at gcc dot gnu.org
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: slyfox at gcc dot gnu.org @ 2021-09-30 8:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102539
--- Comment #1 from Sergei Trofimovich <slyfox at gcc dot gnu.org> ---
Created attachment 51524
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=51524&action=edit
a.c.c.orig
a.c.c.orig is the unreduced preprocessed file with the same warning
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/102539] [11/12 regression] -Wmaybe-uninitialized false positive, invalid <unknown> location
2021-09-30 8:23 [Bug c/102539] New: [11/12 regression] -Wmaybe-uninitialized false positive, invalid <unknown> location slyfox at gcc dot gnu.org
2021-09-30 8:24 ` [Bug c/102539] " slyfox at gcc dot gnu.org
@ 2021-09-30 8:32 ` pinskia at gcc dot gnu.org
2021-09-30 22:38 ` msebor at gcc dot gnu.org
2021-10-01 4:58 ` slyfox at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-09-30 8:32 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102539
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Target Milestone|--- |11.3
Last reconfirmed| |2021-09-30
Status|UNCONFIRMED |NEW
Component|c |tree-optimization
Keywords| |diagnostic
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
The reduced testcase does not match at all the original testcase really.
Here is one which closer represents the original testcase:
void msg_set_buf(const int *);
void clustering_hb_event_listener_buffer_size(int a) {
void* succession_buffer = a>16? __builtin_malloc (a) : __builtin_alloca(a);
msg_set_buf((const int*)succession_buffer);
if (a>16) __builtin_free (succession_buffer);
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/102539] [11/12 regression] -Wmaybe-uninitialized false positive, invalid <unknown> location
2021-09-30 8:23 [Bug c/102539] New: [11/12 regression] -Wmaybe-uninitialized false positive, invalid <unknown> location slyfox at gcc dot gnu.org
2021-09-30 8:24 ` [Bug c/102539] " slyfox at gcc dot gnu.org
2021-09-30 8:32 ` [Bug tree-optimization/102539] " pinskia at gcc dot gnu.org
@ 2021-09-30 22:38 ` msebor at gcc dot gnu.org
2021-10-01 4:58 ` slyfox at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: msebor at gcc dot gnu.org @ 2021-09-30 22:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102539
Martin Sebor <msebor at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |INVALID
CC| |msebor at gcc dot gnu.org
Status|NEW |RESOLVED
--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
-Wmaybe-uninitialized was enhanced to warn when a pointer to uninitialized
memory is passed to a function taking a const-qualified pointer:
... In addition, passing a pointer (or in C++, a reference) to an
uninitialized object to a const-qualified function argument is also diagnosed
by this warning.
That's also what seems to happen in the test case. I get slightly different
output but the essence of the warning seems the same:
$ gcc -O2 -S -Wall -fdump-tree-uninit -fno-strict-aliasing pr102539.c
fabric/clustering.c: In function ‘msg_succession_list_field_set.constprop’:
fabric/clustering.c:3750:2: warning: ‘<unknown>’ may be used uninitialized
[-Wmaybe-uninitialized]
In file included from fabric/clustering.c:36:
/home/slyfox/dev/git/nixpkgs/source/cf/include/msg.h:195:6: note: by argument 3
of type ‘const uint8_t *’ {aka ‘const unsigned char *’} to ‘msg_set_buf’
declared here
tmp$ /build/gcc-master/gcc/xgcc -B /build/gcc-master/gcc -O2 -S -Wall
-fdump-tree-uninit -fno-strict-aliasing -std=gnu99 pr102539.c
fabric/clustering.c: In function ‘msg_succession_list_field_set.constprop’:
fabric/clustering.c:3750:2: warning: ‘<unknown>’ may be used uninitialized
[-Wmaybe-uninitialized]
In file included from fabric/clustering.c:36:
/home/slyfox/dev/git/nixpkgs/source/cf/include/msg.h:195:6: note: by argument 3
of type ‘const uint8_t *’ {aka ‘const unsigned char *’} to ‘msg_set_buf’
declared here
The <unknown> is a known cosmetic flaw with some middle end warnings. It
should be fixed but we don't need to keep track of it here.
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Bug tree-optimization/102539] [11/12 regression] -Wmaybe-uninitialized false positive, invalid <unknown> location
2021-09-30 8:23 [Bug c/102539] New: [11/12 regression] -Wmaybe-uninitialized false positive, invalid <unknown> location slyfox at gcc dot gnu.org
` (2 preceding siblings ...)
2021-09-30 22:38 ` msebor at gcc dot gnu.org
@ 2021-10-01 4:58 ` slyfox at gcc dot gnu.org
3 siblings, 0 replies; 5+ messages in thread
From: slyfox at gcc dot gnu.org @ 2021-10-01 4:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102539
--- Comment #4 from Sergei Trofimovich <slyfox at gcc dot gnu.org> ---
Ah, that's very clever! Thank you!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-10-01 4:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-30 8:23 [Bug c/102539] New: [11/12 regression] -Wmaybe-uninitialized false positive, invalid <unknown> location slyfox at gcc dot gnu.org
2021-09-30 8:24 ` [Bug c/102539] " slyfox at gcc dot gnu.org
2021-09-30 8:32 ` [Bug tree-optimization/102539] " pinskia at gcc dot gnu.org
2021-09-30 22:38 ` msebor at gcc dot gnu.org
2021-10-01 4:58 ` slyfox 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).