public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/101800] New: mingw-64 link error with constexpr static variable definition
@ 2021-08-06 9:55 koncek.marian at gmail dot com
2021-08-06 10:35 ` [Bug c++/101800] " jakub at gcc dot gnu.org
0 siblings, 1 reply; 2+ messages in thread
From: koncek.marian at gmail dot com @ 2021-08-06 9:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101800
Bug ID: 101800
Summary: mingw-64 link error with constexpr static variable
definition
Product: gcc
Version: 10.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: koncek.marian at gmail dot com
Target Milestone: ---
Version:
x86_64-w64-mingw32-g++ (GCC) 10.3.1 20210422 (Fedora MinGW 10.3.1-1.fc34)
Using 3 source files:
////////////////////////////////////
<test.hpp>
#pragma once
struct S
{
const static int value;
};
////////////////////////////////////
<test.cpp>
#include "test.hpp"
constexpr int S::value = 0;
////////////////////////////////////
<main.cpp>
#include "test.hpp"
int main()
{
return S::value;
}
////////////////////////////////////
Compile with:
$ x86_64-w64-mingw32-g++ -std=c++2a -c test.cpp && x86_64-w64-mingw32-g++
-std=c++2a test.o main.cpp
Results in:
/usr/lib/gcc/x86_64-w64-mingw32/10.3.1/../../../../x86_64-w64-mingw32/bin/ld:
/tmp/ccANpWMi.o:main.cpp:(.rdata$.refptr._ZN1S5valueE[.refptr._ZN1S5valueE]+0x0):
undefined reference to `S::value'
collect2: error: ld returned 1 exit status
Whereas plain g++ is able to link the files in the executable.
Changing the `constexpr` definition to `const` makes mingw link the files
successfully.
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug c++/101800] mingw-64 link error with constexpr static variable definition
2021-08-06 9:55 [Bug c++/101800] New: mingw-64 link error with constexpr static variable definition koncek.marian at gmail dot com
@ 2021-08-06 10:35 ` jakub at gcc dot gnu.org
0 siblings, 0 replies; 2+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-08-06 10:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101800
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
CC| |jakub at gcc dot gnu.org
Status|UNCONFIRMED |RESOLVED
--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Dup
*** This bug has been marked as a duplicate of bug 99901 ***
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-06 10:35 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-06 9:55 [Bug c++/101800] New: mingw-64 link error with constexpr static variable definition koncek.marian at gmail dot com
2021-08-06 10:35 ` [Bug c++/101800] " jakub 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).