public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "alvinhochun at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/107751] New: [11/12 regression] False positive -Wmaybe-uninitialized Date: Fri, 18 Nov 2022 13:31:25 +0000 [thread overview] Message-ID: <bug-107751-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107751 Bug ID: 107751 Summary: [11/12 regression] False positive -Wmaybe-uninitialized Product: gcc Version: 12.2.0 Status: UNCONFIRMED Keywords: diagnostic Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: alvinhochun at gmail dot com Target Milestone: --- This test case produces false-positive -Wmaybe-uninitialized warnings: === template <class T1, class T2> bool std_equal(T1* a1, T1* a2, T2* b1); template <class T1, class T2> bool std_equal(T1* a1, T1* a2, T2* b1, T2* b2); template <class T1, class T2> void f() { int a[3] = {1, 2, 3}; T1* x = a; T2* y = a; std_equal(x, x + 3, y); std_equal(y, y + 3, x); std_equal(x, x + 3, y, y + 3); std_equal(y, y + 3, x, x + 3); } int main(int, char**) { f<int, int>(); f<int, const int>(); f<int, volatile int>(); f<int, const volatile int>(); f<const int, const int>(); f<const int, volatile int>(); f<const int, const volatile int>(); f<volatile int, volatile int>(); f<volatile int, const volatile int>(); f<const volatile int, const volatile int>(); return 0; } === Output: === <source>: In function 'void f() [with T1 = const int; T2 = const int]': <source>:12:14: warning: 'a' may be used uninitialized [-Wmaybe-uninitialized] 12 | std_equal(x, x + 3, y); | ~~~~~~~~~^~~~~~~~~~~~~ <source>:2:6: note: by argument 2 of type 'const int*' to 'bool std_equal(T1*, T1*, T2*) [with T1 = const int; T2 = const int]' declared here 2 | bool std_equal(T1* a1, T1* a2, T2* b1); | ^~~~~~~~~ <source>:9:9: note: 'a' declared here 9 | int a[3] = {1, 2, 3}; | ^ <source>: In function 'void f() [with T1 = const int; T2 = volatile int]': <source>:12:14: warning: 'a' may be used uninitialized [-Wmaybe-uninitialized] 12 | std_equal(x, x + 3, y); | ~~~~~~~~~^~~~~~~~~~~~~ <source>:2:6: note: by argument 2 of type 'const int*' to 'bool std_equal(T1*, T1*, T2*) [with T1 = const int; T2 = volatile int]' declared here 2 | bool std_equal(T1* a1, T1* a2, T2* b1); | ^~~~~~~~~ <source>:9:9: note: 'a' declared here 9 | int a[3] = {1, 2, 3}; | ^ <source>: In function 'void f() [with T1 = const int; T2 = const volatile int]': <source>:12:14: warning: 'a' may be used uninitialized [-Wmaybe-uninitialized] 12 | std_equal(x, x + 3, y); | ~~~~~~~~~^~~~~~~~~~~~~ <source>:2:6: note: by argument 2 of type 'const int*' to 'bool std_equal(T1*, T1*, T2*) [with T1 = const int; T2 = const volatile int]' declared here 2 | bool std_equal(T1* a1, T1* a2, T2* b1); | ^~~~~~~~~ <source>:9:9: note: 'a' declared here 9 | int a[3] = {1, 2, 3}; | ^ <source>: In function 'void f() [with T1 = const volatile int; T2 = const volatile int]': <source>:12:14: warning: 'a' may be used uninitialized [-Wmaybe-uninitialized] 12 | std_equal(x, x + 3, y); | ~~~~~~~~~^~~~~~~~~~~~~ <source>:2:6: note: by argument 2 of type 'const volatile int*' to 'bool std_equal(T1*, T1*, T2*) [with T1 = const volatile int; T2 = const volatile int]' declared here 2 | bool std_equal(T1* a1, T1* a2, T2* b1); | ^~~~~~~~~ <source>:9:9: note: 'a' declared here 9 | int a[3] = {1, 2, 3}; | ^ === Compiler Explorer: https://godbolt.org/z/KsM6herr9
next reply other threads:[~2022-11-18 13:31 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-11-18 13:31 alvinhochun at gmail dot com [this message] 2022-11-18 20:01 ` [Bug c++/107751] [11/12/13 regression] False positive -Wmaybe-uninitialized at -O0 pinskia at gcc dot gnu.org 2022-11-18 20:03 ` pinskia at gcc dot gnu.org 2022-11-18 20:06 ` [Bug tree-optimization/107751] " mpolacek at gcc dot gnu.org 2022-12-20 15:56 ` rguenth at gcc dot gnu.org 2023-05-29 10:07 ` [Bug tree-optimization/107751] [11/12/13/14 " jakub at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-107751-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).