From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 245083858D3C; Mon, 24 Jan 2022 10:57:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 245083858D3C From: "f.b.brokken at rug dot nl" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/104202] New: when defining a std::string in a module implementation file using -O2 g++ segfaults Date: Mon, 24 Jan 2022 10:57:10 +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.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: f.b.brokken at rug dot nl 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 24 Jan 2022 10:57:11 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104202 Bug ID: 104202 Summary: when defining a std::string in a module implementation file using -O2 g++ segfaults Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: f.b.brokken at rug dot nl Target Milestone: --- Created attachment 52274 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D52274&action=3Dedit Output of the compiler (segfaults) when compiling 'mod.cc' Using the following main file (main.cc): --------------------------------- #include import mod; int main() { std::cout << modstr << '\n'; } --------------------------------- defining the module mod interface in a separate file (zfirst.cc): --------------------------------- module; #include export module mod; export extern std::string modstr; --------------------------------- and initializing modstr in a separate module implementation file (mod.cc): ------------------------------- module; #include module mod; std::string modstr{ "hello" }; ------------------------------- compiles OK when using the following compiler options: --std=3Dc++20 -Wall -Wextra -fno-strict-aliasing -fwrapv -fmodules-ts but when adding the option -O2 the compiler segfaults (compiler output is attached). Omitting the -Wextra -fno-strict-aliasing -fwrapv options makes= no difference. The compilation was performed on a (yesterday) updated Debian testing distribution using=20 g++ (Debian 12-20211217-1) 12.0.0 20211217 (experimental) [master r12-6027-g774269aa4b9] Copyright (C) 2021 Free Software Foundation, Inc. If you need any additional information, please let me know. Kind regards, Frank.=