public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/100115] New: Bogus -Wmaybe-uninitialized warning with -O3
@ 2021-04-16 13:59 boris at kolpackov dot net
  2021-04-16 16:38 ` [Bug tree-optimization/100115] " msebor at gcc dot gnu.org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: boris at kolpackov dot net @ 2021-04-16 13:59 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 100115
           Summary: Bogus -Wmaybe-uninitialized warning with -O3
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: boris at kolpackov dot net
  Target Milestone: ---

Created attachment 50615
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50615&action=edit
Reproducer

The attached translation unit produces a bogus "may be used uninitialized"
warning:

$ g++-10 -Wmaybe-uninitialized -O3 -std=c++2a -fdirectives-only -c driver.ii
In file included from
/tmp/dist2/libbutl-0.14.0-a.0.20210415102025.fc5599e0a51a/libbutl/utility.mxx:550,
                 from driver.cxx:32:
/tmp/dist2/libbutl-0.14.0-a.0.20210415102025.fc5599e0a51a/libbutl/utility.ixx:
In function ‘int main(int, const char**)’:
/tmp/dist2/libbutl-0.14.0-a.0.20210415102025.fc5599e0a51a/libbutl/utility.ixx:345:17:
warning: ‘ate’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
  345 |     thread_env_ = v;
      |     ~~~~~~~~~~~~^~~
driver.cxx:392:19: note: ‘ate’ was declared here
  392 |   auto_thread_env ate (tevars);
      |                   ^~~

The same with GCC 11:

$ g++-11 -Wmaybe-uninitialized -O3 -std=c++2a -fdirectives-only -c driver.ii
In file included from
/tmp/dist2/libbutl-0.14.0-a.0.20210415102025.fc5599e0a51a/libbutl/utility.mxx:550,
                 from driver.cxx:32:
/tmp/dist2/libbutl-0.14.0-a.0.20210415102025.fc5599e0a51a/libbutl/utility.ixx:
In function ‘int main(int, const char**)’:
/tmp/dist2/libbutl-0.14.0-a.0.20210415102025.fc5599e0a51a/libbutl/utility.ixx:345:17:
warning: ‘*(const char* const**)((char*)&ate + offsetof(butl::auto_thread_env,
butl::auto_thread_env::prev_env.std::optional<const char*
const*>::<unnamed>.std::_Optional_base<const char* const*, true,
true>::<unnamed>))’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
  345 |     thread_env_ = v;
      |     ~~~~~~~~~~~~^~~
driver.cxx:392:19: note: ‘*(const char* const**)((char*)&ate +
offsetof(butl::auto_thread_env,
butl::auto_thread_env::prev_env.std::optional<const char*
const*>::<unnamed>.std::_Optional_base<const char* const*, true,
true>::<unnamed>))’ was declared here
  392 |   auto_thread_env ate (tevars);
      |                   ^~~

In fact, I get a variant of this warning going all the way to GCC 4.9. The
driver.ii file was prepared on Linux (with -fdirectives-only).

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

end of thread, other threads:[~2021-04-17 22:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-16 13:59 [Bug c++/100115] New: Bogus -Wmaybe-uninitialized warning with -O3 boris at kolpackov dot net
2021-04-16 16:38 ` [Bug tree-optimization/100115] " msebor at gcc dot gnu.org
2021-04-17 13:29 ` boris at kolpackov dot net
2021-04-17 22:35 ` 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).