Ich bin mir nicht sicher, was Standard ist.
Code: Select all
// p43.cxx
#include
constinit auto n1 = 9223372036854775807; // 2^63 - 1
static_assert(std::is_same_v);
constinit auto n2 = 9223372036854775808; // 2^63
constinit auto n3 = 18446744073709551615; // 2^64 - 1
#if defined _MSC_VER || defined __clang__
static_assert(std::is_same_v);
static_assert(std::is_same_v);
#elif defined __GNUC__
static_assert(std::is_same_v);
static_assert(std::is_same_v);
#endif
#if defined __GNUC__ && !defined __clang__
constinit auto n4 = 18446744073709551616; // 2^64
static_assert(std::is_same_v);
#endif
< /code>
Syntax-Überprüfung Pässe ohne Fehler: < /p>
g++ -std=c++2c p43.cxx -Wall -Wextra -Wpedantic -fsyntax-only
clang++ -std=c++2c p43.cxx -Wall -Wextra -Wpedantic -fsyntax-only
cl /nologo /std:c++latest /nologo /Wall /wd4577 p43.cxx /Zs
Seeing that I've only used decimal literals, if I've understood the wording in the current draft correctly, [lex.icon]/3 says that one of int, long int or long long int should be picked. /4 ermöglicht die Verwendung eines erweiterten Ganzzahltyps, wenn diese nicht verwendet werden können, die sich von den Standards wie pro [Basic.Fundamental]/1,2,5 unterscheiden. MSVC emittiert keine Warnungen, Clang emittiert diese Warnung: < /p>
Warnung: Integer buchstäblich ist zu groß, um in einem signierten Ganzzahl dargestellt zu werden, und die Interpretation als unsigned "< /p> < /> < /blockquote>
werden schlecht geformt, wenn __INT128 nicht unterstützt wird? signiert __INT128 . Warum ist das so? < /P>
Bearbeiten (basierend auf Kommentar): Ich habe meine Plattform nicht angegeben.
PC Windows x86-64 LLP64 < /P.>