[llvm-bugs] [Bug 47295] New: Invalid error on long long literal -9223372036854775808LL as a long long array value

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Aug 24 00:47:11 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=47295

            Bug ID: 47295
           Summary: Invalid error on  long long literal
                    -9223372036854775808LL as a  long long array value
           Product: clang
           Version: 6.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: francis.andre.kampbell at orange.fr
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

Hello

Compiling the sample below;
static const long long jjlonglong = -9223372036854775808LL;
static const long long jjlonglong1 = 0xFFFFFFFFFFFFFFFF;

static const long long jjCharData[][41] = {
        {2LL, 1LL, -9223372036854775808LL}
};

int main() {
        return 0;
}

Clang is producing those messages
x.cpp:2:38: warning: integer literal is too large to be represented in a signed
integer type, interpreting as unsigned [-Wimplicitly-unsigned-literal]
static const long long jjlonglong = -9223372036854775808LL;
                                     ^
x.cpp:6:14: warning: integer literal is too large to be represented in a signed
integer type, interpreting as unsigned [-Wimplicitly-unsigned-literal]
        {2LL, 1LL, -9223372036854775808LL}
                    ^
x.cpp:6:13: error: constant expression evaluates to 9223372036854775808 which
cannot be narrowed to type 'long long' [-Wc++11-narrowing]
        {2LL, 1LL, -9223372036854775808LL}
                   ^~~~~~~~~~~~~~~~~~~~~~
x.cpp:6:13: note: insert an explicit cast to silence this issue
        {2LL, 1LL, -9223372036854775808LL}
                   ^~~~~~~~~~~~~~~~~~~~~~
                   static_cast<long long>( )


The same long long literal as -9223372036854775808LL should produce the same
warning, be used as initializer of a simple variable or a long long array
member.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200824/0d547f1c/attachment-0001.html>


More information about the llvm-bugs mailing list