Wandbox
SettingsLog
SettingsLog
Language
GitHubLogin
Ran/Viewed Log

Author

anonymous

over 5 years ago

Language

C++

Compiler

clang HEAD 10.0.0 (https://github.com/llvm-mirror/clang.git 65acf43270ea2894dffa0d0b292b92402f80c8cb) (https://github.com/llvm-mirror/llvm.git 2c4ca6832fa6b306ee6a7010bfb80a3f2596f824)

Options
Warnings
Boost 1.71.0
C++2a(GNU)
no pedantic

Author

anonymous

over 5 years ago

$ clang++ prog.cc -Wall -Wextra -I/opt/wandbox/boost-1.71.0/clang-head/include -std=gnu++2a
prog.cc:7:11: error: cannot combine with previous 'constinit' declaration specifier
constinit constexpr int L = 1;  //ng、constinitとconstexprを同時に指定できない
          ^
prog.cc:12:18: error: variable does not have a constant initializer
constinit double PI2 = PI + PI;     //ng、変数PIは定数式で利用不可
                 ^     ~~~~~~~
prog.cc:12:1: note: required by 'constinit' specifier here
constinit double PI2 = PI + PI;     //ng、変数PIは定数式で利用不可
^~~~~~~~~
prog.cc:12:24: note: read of non-constexpr variable 'PI' is not allowed in a constant expression
constinit double PI2 = PI + PI;     //ng、変数PIは定数式で利用不可
                       ^
prog.cc:11:24: note: declared here
constinit const double PI = 3.1415; //ok
                       ^
prog.cc:20:22: warning: 'extern' variable has an initializer [-Wextern-initializer]
constinit extern int def = 10;  //ok
                     ^
prog.cc:30:14: warning: 'constinit' specifier missing on initializing declaration of 'x' [-Wmissing-constinit]
const int S::x = 12;            //ok、constinit変数なので定数初期化される
             ^
constinit 
prog.cc:25:3: note: variable declared constinit here
  constinit static const int x;
  ^
prog.cc:32:11: error: cannot combine with previous 'constinit' declaration specifier
constinit constexpr int S::z;   //ng、インライン変数に対する多重定義
          ^
prog.cc:32:1: error: 'constinit' specifier added after initialization of variable
constinit constexpr int S::z;   //ng、インライン変数に対する多重定義
^~~~~~~~~~
prog.cc:27:24: note: add the 'constinit' specifier to the initializing declaration here
  static constexpr int z = 56;
                       ^
  constinit 
prog.cc:32:28: error: redefinition of 'z' with a different type: 'int' vs 'const int'
constinit constexpr int S::z;   //ng、インライン変数に対する多重定義
                           ^
prog.cc:27:24: note: previous definition is here
  static constexpr int z = 56;
                       ^
prog.cc:37:39: error: variable does not have a constant initializer
  constinit thread_local std::mt19937 engine(std::random_device{}()); //ng、定数式で初期化できない
                                      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prog.cc:37:3: note: required by 'constinit' specifier here
  constinit thread_local std::mt19937 engine(std::random_device{}()); //ng、定数式で初期化できない
  ^~~~~~~~~
prog.cc:37:39: note: non-constexpr constructor 'mersenne_twister_engine' cannot be used in a constant expression
  constinit thread_local std::mt19937 engine(std::random_device{}()); //ng、定数式で初期化できない
                                      ^
/opt/wandbox/clang-head/include/c++/v1/random:2110:14: note: declared here
    explicit mersenne_twister_engine(result_type __sd = default_seed)
             ^
prog.cc:39:3: error: local variable cannot be declared 'constinit'
  constinit int local = 0;  //ng、ローカル変数
  ^
2 warnings and 7 errors generated.
Exit Code:
1