From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 634903858D32; Thu, 13 Apr 2023 07:25:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 634903858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681370737; bh=PGbuTOYPjagH0/E+K1lZVMnnL8zcco1EkIqxVjqXzg8=; h=From:To:Subject:Date:From; b=RMwESWQMnSNoC9SLVmV4rMhuy3CaSyYW5j3vG8q3yZkSj9/ggO437SDJTIlD8hbXN PyEJ3nIz4ZiS1HUAYBUPfCbJ9emMtHwD0gsxYZtVJ38kWiL/+GmTrkI1vsXpCxK24B K4TzuJs2R31mHmGUpkR0d8U5lATEHB4FoNrP1h3A= From: "oliver.rosten at googlemail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/109494] New: inline const variables interfere with source_location Date: Thu, 13 Apr 2023 07:25:36 +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.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: oliver.rosten at googlemail dot com 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 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=3D109494 Bug ID: 109494 Summary: inline const variables interfere with source_location Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: oliver.rosten at googlemail dot com Target Milestone: --- The bug, (for which I'm not sure if it is a front end problem or a library problem), is reproduced here: https://github.com/ojrosten/SourceLoc The project comprises three files in the Test directory: Main.cpp Test.cpp Test.hpp Both the cpps depend on the hpp. The latter contains an unused variable inline const std::string foo{}; The presence of this seems to cause: 1. The appearance of a warning: "ld: warning: direct access in function ... from file ... to global weak symbol ... from file ... means the weak symbol cannot be overridden at runtime..." 2. std::source_location::current() to misbehave: building and running causes the path to Main.cpp to be output twice, whereas it should just be printed once, with the path to Test.cpp appearing second. Any of the following cures both of the problems: 1. Removing foo; 2. Removing inline; 3. Replacing const with constexpr In the much more complex project where I first encountered this, I reliably= got a segmentation fault. I was able to cure this by removing inline in a handf= ul of places.=