Comments (2)
Hello @Ukilele,
that looks like an interesting question. From the paragraphs you quote, I agree your interpretation seems correct.
If we look at the AST from Clang (compiler-explorer.com/z/K3f5jzscE) we can see that B
's operator is not constexpr
. The behavior of C++ Insights matches what Clang thinks.
Now, there is one piece missing, which I couldn't find quickly. It does not make sense to mark the assignment operators constexpr
in B
since we can never use them in a constexpr
context. For example, the compilation fails if you uncomment line 13 in the Compiler Explorer link.
I can see that eel.is/c++draft/dcl.constexpr#3 does not say that, which is confusing. I'll ask WG21 whether there is some text missing or there is a sub-clause somewhere addressing this behavior.
Andreas
from cppinsights.
Hi Andreas,
thanks a lot for your comprehensive response.
I agree that B
is a contrived example. Having a class with a constexpr assignment operator but with a non-constexpr destructor is at most useful for theoretical discussions. I just was playing around on cppinsights, because it was not completely clear to me when a defaulted special member function is constexpr or noexcept and your tool is very helpful to find that out!
The reason that line 13 fails to compile is, because the destructor of B
is user-provided (showstopper for C++17) and not marked as constexpr (showstopper for C++20). But you are right, I think we can never actually use them in a constexpr context, because we can't use B
in a constexpr context, as it's destructor is not constexpr.
So far I still think that the assignment operators of B
, D
and D<false>
should be marked constexpr. But I see that the issue would be on Clang and not on cppinsights.
from cppinsights.
Related Issues (20)
- [document] Vim plugin for cppinsights HOT 1
- cpp coro recursively task "coroutine transformation" wrong HOT 1
- Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it) HOT 2
- cppinsights crash with stack dump HOT 3
- The `type` in `typeid(type)` gets replaced by `const std::type_info` HOT 2
- [BUG] Code Example Doesn't Compile HOT 2
- Missing Clang 16 support HOT 1
- CppInsights crash with stack dump HOT 2
- for-loops as while-loops is wrong for ranged-based for loop HOT 2
- for-loops as while-loops is wrong for ranged-based for loop HOT 1
- for-loops as while-loops is wrong for ranged-based for loop HOT 1
- for-loops as while-loops is wrong for ranged-based for loop HOT 1
- for-loops as while-loops is wrong for ranged-based for loop HOT 1
- for-loops as while-loops is wrong for ranged-based for loop HOT 1
- for-loops as while-loops is wrong for ranged-based for loop HOT 1
- Can I use #include <Windows.h> with cppinsights? HOT 4
- coroutine transformation: Support _promise-constructor-arguments_ HOT 5
- [BUG] with getting a global variable HOT 1
- Generated insight for `jmp_buf` global variable declarations. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cppinsights.