On Fri, 7 Feb 2020 at 19:51, FRANČEK PRIJATELJ via cfe-users <
[email protected]> wrote:
> /*
>
> Following code compiled with clang-cl on win10 generates 2 errors
> (while the same code compiled with MS cl compiles):
>
> t1.cpp(12,35): error: in-class initializer for static data member is not
> a constant expression
> static const int64_t MIN_VALUE = -0x8000000000000000LL;
> ^~~~~~~~~~~~~~~~~~~~~
> t1.cpp(15,39): error: in-class initializer for static data member is not
> a constant expression
> static const int64_t MIN_VALUE1 = -9223372036854775808LL;
> ^~~~~~~~~~~~~~~~~~~~~~
> 2 errors generated.
>
These expressions have undefined behavior due to exhibiting signed
overflow, and so are non-constant in C++11 onwards.
*/
>
> #include <string>
>
> static const int64_t MAX_VALUE = 0x7fffffffffffffffLL;
> static const int64_t MIN_VALUE = -0x8000000000000000LL;
>
> static const int64_t MAX_VALUE1 = 9223372036854775807LL;
> static const int64_t MIN_VALUE1 = -9223372036854775808LL;
>
>
> class X {
> static const int64_t MAX_VALUE = 0x7fffffffffffffffLL;
> static const int64_t MIN_VALUE = -0x8000000000000000LL;
>
> static const int64_t MAX_VALUE1 = 9223372036854775807LL;
> static const int64_t MIN_VALUE1 = -9223372036854775808LL;
> };
>
>
> _______________________________________________
> cfe-users mailing list
> [email protected]
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users
>
_______________________________________________
cfe-users mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users