From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 198153857709; Tue, 20 Jun 2023 18:26:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 198153857709 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687285594; bh=2oCbGzVLYgKuNXxWmw9S3O6Mm374O3+xcc/3kVm3mqU=; h=From:To:Subject:Date:From; b=eeVB8NG61AzpCBLk0jwLPYpai53NIO11c6gIbcKQucOhAk5sScB+IrphZ+3pJPgfu 0MCHKec7xNrYORKwHdL8IyqToqpin4gGgx6Wjb49xB76KTAywq7SxYk7vZFDmktbjU y+BCJOVKvYkN/dG3ljr/FsQSExyvdjfvzuQIoAgs= From: "m-matti-a.lehtonen at iki dot fi" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/110328] New: Module related optimization is too aggressive Date: Tue, 20 Jun 2023 18:26:33 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.3.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: m-matti-a.lehtonen at iki dot fi X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110328 Bug ID: 110328 Summary: Module related optimization is too aggressive Product: gcc Version: 12.3.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: m-matti-a.lehtonen at iki dot fi Target Milestone: --- Created attachment 55375 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D55375&action=3Dedit Example sources When the module example (files test.cc and test2.cc) is compiles as > g++-12 --std=3Dc++20 -Wall -Wextra -Werror -pedantic -fmodules-ts -O1 -= DNDEBUG test2.cc test.cc it generates the following error: > In file included from test.cc:4, > of module test, imported at test2.cc:5: > In destructor =E2=80=98virtual std::bad_optional_access::~bad_optional_ac= cess()=E2=80=99, > inlined from =E2=80=98virtual std::bad_optional_access::~bad_optional= _access()=E2=80=99 at > test2.cc:8:15: > /usr/include/c++/12/optional:102:13: error: =E2=80=98this=E2=80=99 is use= d uninitialized [-Werror=3Duninitialized] > 102 | virtual ~bad_optional_access() =3D default; > | ^ > In file included from test2.cc:2: > /usr/include/c++/12/optional: In destructor =E2=80=98virtual std::bad_opt= ional_access::~bad_optional_access()=E2=80=99: > /usr/include/c++/12/optional:102:13: note: =E2=80=98this=E2=80=99 was dec= lared here > 102 | virtual ~bad_optional_access() =3D default; > | ^ If the if statement at test2.cc is uncommented, no error is generated. If basically the same code (file test3.cc) is compiled without using module= s, no problem > g++-12 --std=3Dc++20 -Wall -Wextra -Werror -pedantic -O1 -DNDEBUG test3.= cc Exact version and system (Ubuntu 22.04.2 LTS) > $ g++-12 --version > g++-12 (Ubuntu 12.3.0-1ubuntu1~22.04) 12.3.0=