[llvm-bugs] [Bug 51883] New: Undefined Reference to static constexpr when compiling with -fprofile-instr-generate
via llvm-bugs
llvm-bugs at lists.llvm.org
Thu Sep 16 15:28:38 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=51883
Bug ID: 51883
Summary: Undefined Reference to static constexpr when compiling
with -fprofile-instr-generate
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: C++14
Assignee: unassignedclangbugs at nondot.org
Reporter: thoren.paulson at gmail.com
CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk
Godbolt link: https://godbolt.org/z/vqEjKEKch
When I compile the following code with `-Oz -std=c++14
-fprofile-instr-generate`, it refers to the undefined symbol kUndefined, which
causes "undefined reference" at link time.
```
#include <algorithm>
class Foo {
private:
static constexpr int kUndefined = 4;
public:
int Bar(int a);
};
int Foo::Bar(int a) {
return std::max(a, kUndefined);
}
```
It seems this is because std::max takes its arguments by reference, so if it
doesn't get inlined (consequence of -Oz), code is generated referring to
kUndefined, but there is no code generated to define kUndefined.
--
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/20210916/bb500d9f/attachment.html>
More information about the llvm-bugs
mailing list