Tags down


Can a core constant expression contain an ignored reinterpret_cast?

By : Robert Downey
Date : July 31 2020, 12:00 AM
Does that help A core constant expression cannot contain a reinterpret_cast even if its value is discarded (so MSVC and Clang are right to reject the code). See C++17 [expr.const]/2.15:
code :
enum {
    Value = 1 || reinterpret_cast<uintptr_t>(&x);  // OK

Share : facebook icon twitter icon

What is a core constant expression in the C++11 Standard?

By : Programmer_N_Progres
Date : March 29 2020, 07:55 AM
Does that help N3690 does define the term "core constant expression in 5.19p2 [expr.const]:
code :
const double x = 2.;
constexpr double y = x;
constexpr double x = 2.;
constexpr double y = x;

`core constant expression` vs `constant expression`

By : Jaryl Chong
Date : March 29 2020, 07:55 AM
To fix the issue you can do The definition of a core constant expression depends on the concept of a constant expression as can be seen in bullet points (2.7.1) and (2.9.1) of N4140. , The definitions are mutually recursive, but not actually circular.

Why doesn't an if constexpr make this core constant expression error disappear?

By : unwabuisi
Date : March 29 2020, 07:55 AM
will be helpful for those in need The standard doesn't say much about the discarded statement of an if constexpr. There are essentially two statements in [stmt.if] about these:
In an enclosing template discarded statements are not instantiated. Names referenced from a discarded statement are not required ODR to be defined.
code :
template <typename T>
void f() {
    constexpr int x = -1;
    if constexpr (x >= 0){
        constexpr int y = 1<<x;
template <typename T>
void f() {
    constexpr T x = -1;
    if constexpr (x >= 0){
        constexpr int y = 1<<x;
int main() {

Core constant expression and array indexing

By : Jawwad
Date : March 29 2020, 07:55 AM
may help you . Supporting variable-length arrays is a compiler extension, which the standard generally permits as long as it doesn't make conformant code behave differently, and as long as they say that it's an extension (which GCC does with that warning):

Is there a constant expression that is not a core constant expression?

By : Phillip Archer
Date : March 29 2020, 07:55 AM
should help you out [expr.const]/5 defines "constant expression" as:
Related Posts Related Posts :
  • Compiling standard library types
  • Sending argument to an .exe via SHELLEXECUTEINFO
  • Why I can't use i/10 in FOR LOOP, C++?
  • How to use PERF_SAMPLE_READ with mmap
  • Is there any way to iterate through a struct?
  • My character counting code is miscounting characters. Why?
  • Difference between std::resize(n) and std::shrink_to_fit in C++?
  • Wildcard for C++ concepts saying "accepting anything for this template argument"
  • Which of the objects of the class A would be created first in this code snippet?
  • Floating point math accuracy, c++ vs fortran
  • C++ initialize objects with packed array of integers
  • Picking a constructor to call
  • using function call in constructor gives different result c++
  • Using strcpy to copy elements of an char array to another array
  • Templated Constructor Specialization
  • Struggling to convert an integer into a linked list. Not sure what I'm doing wrong here
  • C++: Is it better to store a console output in a macro?
  • C++ - Exception in Constructor
  • AVX: matrix dot vector, but ignore diagonal
  • Pointer To Pointer passed by reference
  • Why is this operator< overload function invisible to STL algorithms?
  • What is the correct algorithm to perform double-float division?
  • In the case of using a std::unique_ptr to automatically deallocate memory upon exiting a scoped block, why not just use
  • C++: Iterating over a string vector and using the index for putenv
  • OpenCL Matrix Multiplication Using std::vector
  • template template parameter deduction: three different compilers three different behaviors
  • C++ pull a card from deck
  • File reading with and without new line
  • store strings in stable memory in c++
  • Why is static_cast used in QT's official document
  • iterator .end() from std::list returns "0xcdcdcdcdcdcdcdcd" but .begin() as expected
  • Is std::sqrt the same as sqrt in C++
  • Iterate through std::initializer_list
  • Codeblocks c++ code doesn't run in VS 19 (vector subscript out of range)
  • Why erase on std::vector promote iterator
  • how to destroy an object in C++
  • How to create Visual Studio 2015 solution from CMake
  • Using concepts for checking if a type T has a field F
  • constructor giving error: no matching function for call to
  • search top n% of a vector member C++
  • Is this reinterpret_cast problematic in principle, and/or in practice?
  • What is the following error doing? I do not see any error with the bounds
  • Two index's of an array have same memory adress
  • how do i avoid integer division in c++?
  • Setting value to enum
  • Properties of a pointer to a zero length array
  • Why the output is different how ever the formula is the same?
  • Restarting from the beginning using do while loops
  • Error: invalid initialization of reference of type
  • how to avoid to use memcpy to create a string
  • Copying the vector elements into std::array
  • Is there any class pointers in Perl in order to access member variables and functions?
  • Why the static variable is not set to 1000
  • Why can't a destructor have reference qualifiers?
  • How to print binary tree in horizontal way?
  • Comparison behavior of ' <' operator
  • Constructors in C++ Language
  • Why displayed value of b , c and y is different from my trace?
  • Undefined reference to `fftw_init_threads' while installing pHash library
  • Reading remapped hdd sectors
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org