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

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler@googlemail.
                   |                            |com

--- Comment #3 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
(In reply to Lénárd Szolnoki from comment #2)
> I failed to mention that I compiled the example in -std=c++17. With this
> compiler option it compiles but fails to link in gcc. It compiles, links and
> runs as expected in clang.
> 
> The linkage requirement for reference/pointer non-type template arguments
> were lifted in C++17.

According to https://gcc.gnu.org/bugs/ the compile options have to be provided
for every bug report. Here is a slightly simplified reproducer free of any
library dependencies:

Compiler options:

-Wall -Wextra -std=c++2a -pedantic

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

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

void bar(const int*){}

int main() {
    bar(decltype(foo())::value);
}
//---------------

Diagnostic output:

//----------------
/tmp/cci6dPre.o: In function `main':
prog.cc:(.text+0x10): undefined reference to `foo()::i'
collect2: error: ld returned 1 exit status
//----------------

Reply via email to