public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "daniel.kruegler at googlemail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/95686] undefined reference to static local variable within inline function
Date: Tue, 16 Jun 2020 17:37:24 +0000 [thread overview]
Message-ID: <bug-95686-4-eLtqYQ4Obq@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-95686-4@http.gcc.gnu.org/bugzilla/>
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
//----------------
next prev parent reply other threads:[~2020-06-16 17:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-15 17:51 [Bug c++/95686] New: " 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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-95686-4-eLtqYQ4Obq@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).