From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id C29D03858280; Wed, 7 Jun 2023 02:26:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C29D03858280 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1686104808; bh=XOlbiL3UsJDM3I84XQUl5LS/9P0JqNRBt/g58P+OYJg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=UVuGM68xT9m9eG/XYxzTaXbTE9BMj+BaQ7bs1nyDyGIPpcY606t+O9IFUzxJ6R9ot ytDwQOhpHWGWvx9J2UV53zq9uWLRx6mG7C59Ps+4F5ndVRhjJ63L8IPnUI0DnB4UxW BfT+43neqEhzkq74loAK6IMqVbJdFXMQm+fDSV+A= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/98105] constexpr and unnamed namespace yields relocation R_X86_64_PC32 against undefined symbol ... can not be used when making a shared object; recompile with -fPIC Date: Wed, 07 Jun 2023 02:26:48 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org X-Bugzilla-Status: NEW 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: Message-ID: In-Reply-To: References: 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=3D98105 --- Comment #3 from Andrew Pinski --- Reduced: ``` void f(const int&); namespace { struct myFactory { static constexpr int s_sList =3D 1; }; } //constexpr int myFactory::s_sList; void sdi_register_model() { f(myFactory::s_sList); } ``` If we uncomment the definition, it works. I think this is correct behavior, just we should produce a better error mes= sage of not have the definition and only the declaration here.=