public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug c++/98105] New: 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 @ 2020-12-02 19:03 peter_foelsche at mentor dot com 2020-12-03 7:26 ` [Bug c++/98105] " rguenth at gcc dot gnu.org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: peter_foelsche at mentor dot com @ 2020-12-02 19:03 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98105 Bug ID: 98105 Summary: 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 Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: peter_foelsche at mentor dot com Target Milestone: --- Created attachment 49665 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49665&action=edit g++-10 -std=c++11 2.cxx -shared -fPIC please compile with g++-10 -std=c++11 2.cxx -shared -fPIC This is g++: g++-10 (Ubuntu 10.2.0-5ubuntu1~20.04) 10.2.0 Copyright (C) 2020 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [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 2020-12-02 19:03 [Bug c++/98105] New: 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 peter_foelsche at mentor dot com @ 2020-12-03 7:26 ` rguenth at gcc dot gnu.org 2020-12-03 13:06 ` peter_foelsche at mentor dot com 2023-06-07 2:26 ` pinskia at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: rguenth at gcc dot gnu.org @ 2020-12-03 7:26 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98105 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Keywords| |wrong-code Ever confirmed|0 |1 Last reconfirmed| |2020-12-03 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- So somehow we are not emitting namespace { class myFactory:public factory { public: static constexpr LIST s_sList = { {1.0, 0} }; ... }; } but I'm not literate enough in C++ to tell if there's a definition missing. It works with -std=c++17 but not with -std=c++11 or -std=c++14 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [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 2020-12-02 19:03 [Bug c++/98105] New: 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 peter_foelsche at mentor dot com 2020-12-03 7:26 ` [Bug c++/98105] " rguenth at gcc dot gnu.org @ 2020-12-03 13:06 ` peter_foelsche at mentor dot com 2023-06-07 2:26 ` pinskia at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: peter_foelsche at mentor dot com @ 2020-12-03 13:06 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98105 --- Comment #2 from Peter Foelsche <peter_foelsche at mentor dot com> --- sorry -- adding a definition outside of class for the variable solves the problem! ^ permalink raw reply [flat|nested] 4+ messages in thread
* [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 2020-12-02 19:03 [Bug c++/98105] New: 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 peter_foelsche at mentor dot com 2020-12-03 7:26 ` [Bug c++/98105] " rguenth at gcc dot gnu.org 2020-12-03 13:06 ` peter_foelsche at mentor dot com @ 2023-06-07 2:26 ` pinskia at gcc dot gnu.org 2 siblings, 0 replies; 4+ messages in thread From: pinskia at gcc dot gnu.org @ 2023-06-07 2:26 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98105 --- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Reduced: ``` void f(const int&); namespace { struct myFactory { static constexpr int s_sList = 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 message of not have the definition and only the declaration here. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-06-07 2:26 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-12-02 19:03 [Bug c++/98105] New: 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 peter_foelsche at mentor dot com 2020-12-03 7:26 ` [Bug c++/98105] " rguenth at gcc dot gnu.org 2020-12-03 13:06 ` peter_foelsche at mentor dot com 2023-06-07 2:26 ` pinskia at gcc dot gnu.org
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).