[llvm-bugs] [Bug 38106] Undefined reference error when "static const" variable is initialized in line (but works out of line)
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Jul 9 10:23:08 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=38106
David Blaikie <dblaikie at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |INVALID
CC| |dblaikie at gmail.com
--- Comment #1 from David Blaikie <dblaikie at gmail.com> ---
This code (with the static member definition commented out) exhibits undefined
behavior due to an ODR use of 'foo' without a definition of 'foo'.
The "const static long long foo = 5;" (even with the "= 5") is only a
declaration of foo and must have an out of line definition (the initial value
("= 5") can remain in the declaration if you want/for various reasons).
If you want to keep the initial value inline at the declaration, then omit the
initial value in the definition (write it as "const long long Foo::foo;").
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180709/251ce25c/attachment.html>
More information about the llvm-bugs
mailing list