public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/95686] New: undefined reference to static local variable within inline function
@ 2020-06-15 17:51 leni536 at gmail dot com
  2020-06-16  6:40 ` [Bug c++/95686] " rguenth at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: leni536 at gmail dot com @ 2020-06-15 17:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95686

            Bug ID: 95686
           Summary: undefined reference to static local variable within
                    inline function
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: leni536 at gmail dot com
  Target Milestone: ---

The following code produces an "undefined reference to `foo()::i'" linker
error:

template <const int* ptr>
struct S {
    static constexpr const int* value = ptr;
};

inline
auto foo() {
    static const int i = 0;
    return S<&i>{};
}

#include <iostream>

int main() {
    std::cout << decltype(foo())::value;
}

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-03-19 19:07 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-15 17:51 [Bug c++/95686] New: undefined reference to static local variable within inline function leni536 at gmail dot com
2020-06-16  6:40 ` [Bug c++/95686] " rguenth at gcc dot gnu.org
2020-06-16  7:14 ` leni536 at gmail dot com
2020-06-16 17:37 ` daniel.kruegler at googlemail dot com
2021-08-13  8:25 ` pinskia at gcc dot gnu.org
2021-10-13  3:30 ` pinskia at gcc dot gnu.org
2021-10-13  3:32 ` pinskia at gcc dot gnu.org
2023-03-19 19:05 ` pinskia at gcc dot gnu.org
2023-03-19 19:06 ` pinskia at gcc dot gnu.org
2023-03-19 19:07 ` 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).