[llvm-bugs] [Bug 45534] New: __builtin_constant_p ignores destructors with side-effects
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Apr 14 10:58:32 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=45534
Bug ID: 45534
Summary: __builtin_constant_p ignores destructors with
side-effects
Product: clang
Version: trunk
Hardware: All
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: hstong at ca.ibm.com
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
Given an expression that creates a temporary with a non-trivial destructor that
has side-effects, Clang still manages to evaluate `__builtin_constant_p` of
said expression to `1`.
I am not sure that it is clear whether `__builtin_constant_p` is considered a
full-expression context. I think not treating it as one is more conservative.
In either case though, calling or registering a destructor whose definition is
unknown can hardly be considered to not have side-effects.
### SOURCE (<stdin>):
struct S { ~S(); };
static_assert(!__builtin_constant_p((S{}, 42)), "");
### COMPILER INVOCATION:
clang -cc1 -fsyntax-only -xc++ -
### EXPECTED OUTPUT:
(clean compile)
### ACTUAL OUTPUT:
<stdin>:2:1: error: static_assert failed due to requirement
'!__builtin_constant_p((S{} , 42))' ""
static_assert(!__builtin_constant_p((S{}, 42)), "");
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
### COMPILER VERSION INFO (clang -v):
clang version 11.0.0 (https://github.com/llvm/llvm-project.git
4d9f5f135fad9eafa78ded8589af99a593415102)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/wandbox/clang-head/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/5.4.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@mx32
Selected multilib: .;@m64
--
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/20200414/f5d41f67/attachment.html>
More information about the llvm-bugs
mailing list