public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "janisozaur+gcc at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/105937] New: [12] Regression with maybe-uninitialized
Date: Sun, 12 Jun 2022 22:12:38 +0000	[thread overview]
Message-ID: <bug-105937-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 105937
           Summary: [12] Regression with maybe-uninitialized
           Product: gcc
           Version: 12.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: janisozaur+gcc at gmail dot com
  Target Milestone: ---

Created attachment 53125
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53125&action=edit
Test case extracted from original code

Commit https://gcc.gnu.org/g:6feb628a706e86eb3f303aff388c74bdb29e7381 "Improve
warning suppression for inlined functions [PR98512]. " introduced a regression
when using std::optional.

Ever since that commit, when building optimized code compiler complains:

/home/mijn/workspace/openrct2/src/openrct2/drawing/Drawing.String.cpp: In
function ‘void ttf_process_string_literal(OpenRCT2::IContext*,
std::string_view)’:
/home/mijn/workspace/openrct2/src/openrct2/drawing/Drawing.String.cpp:215:62:
error: ‘*(long unsigned int*)((char*)&ttfRunIndex + offsetof(std::optional<long
unsigned int>,std::optional<long unsigned
int>::<unnamed>.std::_Optional_base<long unsigned int, true,
true>::<unnamed>))’ may be used uninitialized in this function
[-Werror=maybe-uninitialized]
  215 |                 auto len = it.GetIndex() - ttfRunIndex.value();
      |                                                              ^


gcc -v:

Using built-in specs.
COLLECT_GCC=/home/mijn/workspace/gcc-install-master/bin/c++
COLLECT_LTO_WRAPPER=/home/mijn/workspace/gcc-install-master/libexec/gcc/x86_64-pc-linux-gnu/12.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure
--prefix=/home/mijn/workspace/gcc-install-master --enable-languages=c++
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 12.0.0 20210702 (experimental) (GCC)



Provided an extracted test case for the issue mentioned.
Original code:
https://github.com/OpenRCT2/OpenRCT2/blob/b0ffa9d28e62b862f68a37788931265cb4528835/src/openrct2/drawing/Drawing.String.cpp#L839
Original bug report for OpenRCT2:
https://github.com/OpenRCT2/OpenRCT2/issues/17371
Test case on godbolt: https://godbolt.org/z/6Y3cn1Ks1

c++ -O2 -c -o foo test.cpp -Werror=maybe-uninitialized

             reply	other threads:[~2022-06-12 22:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-12 22:12 janisozaur+gcc at gmail dot com [this message]
2022-06-12 22:16 ` [Bug tree-optimization/105937] " pinskia at gcc dot gnu.org
2022-06-12 22:25 ` [Bug tree-optimization/105937] [12/13 Regression] maybe-uninitialized with std::optional pinskia at gcc dot gnu.org
2022-10-11 12:06 ` [Bug tree-optimization/105937] [12 " cvs-commit at gcc dot gnu.org
2022-10-11 12:08 ` rguenth 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-105937-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: link
Be 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).