https://bugs.llvm.org/show_bug.cgi?id=43270
Bug ID: 43270
Summary: Improper handling of __declspec(selectany) constexpr
in clang-cl /std:c++17
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: -New Bugs
Assignee: unassignedclangb...@nondot.org
Reporter: epas...@google.com
CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org,
neeil...@live.com, richard-l...@metafoo.co.uk
Created attachment 22484
--> https://bugs.llvm.org/attachment.cgi?id=22484&action=edit
Minimal reproduction
For MSVC compatibility, clang-cl replicates a non-standard behavior creating
implicit definitions for static const (including constexpr) members.
According to Microsoft documentation, to accommodate these, we're supposed to
use __declspec(selectany) as a guard on the out-of-class definition. [1]
However... if we pass /std:c++17 or /std:c++2a to clang-cl when compiling a
source file including an out-of-class definition, clang-cl emits the following
warning:
=====
selectany.cc(13,1): warning: attribute declaration must precede definition
[-Wignored-attributes]
SELECTANY constexpr int CMyClass::val;
^
selectany.cc(8,30): note: expanded from macro 'SELECTANY'
#define SELECTANY __declspec(selectany)
^
selectany.cc(3,24): note: previous definition is here
static constexpr int val = 0;
=====
No such warning appears if we pass /std:c++14 instead.
Minimal reproduction attached.
[1]:
https://docs.microsoft.com/en-us/cpp/build/reference/microsoft-extensions-to-c-and-cpp?view=vs-2019
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs