fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. // works.
  5. constexpr unsigned char arr[sizeof(unsigned long long)]{ 1 };
  6. constexpr bool value = static_cast<const unsigned long long&>(arr[0]) == 1;
  7.  
  8.  
  9. // doesn't.
  10. //unsigned char arr2[sizeof(unsigned long long)]{1};
  11. //bool value2 = static_cast<unsigned long long&>(arr[0]) == 1;
  12.  
  13. int main() {
  14. // your code goes here
  15. return 0;
  16. }
Compilation error #stdin compilation error #stdout 0s 3408KB
stdin
Standard input is empty
compilation info
prog.cpp:8:54: error: invalid static_cast from type 'const unsigned char' to type 'long long unsigned int&'
 bool value2 = static_cast<unsigned long long&>(arr[0]) == 1;
                                                      ^
stdout
Standard output is empty