Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Illegitimate implicitly-unsigned-literal warning for LLONG_MIN value. #32509

Closed Quuxplusone closed 7 years ago

Quuxplusone commented 7 years ago
Bugzilla Link PR33537
Status RESOLVED INVALID
Importance P enhancement
Reported by Dmitry Babokin (babokin@gmail.com)
Reported on 2017-06-20 18:16:17 -0700
Last modified on 2017-06-21 09:50:22 -0700
Version trunk
Hardware PC All
CC babokin@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk, Vsevolod.Livinskij@frtk.ru
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
clang trunk, x86_64.

Using long long literal with LLONG_MIN value causes illegitimate warning. Note
using LLONG_MIN macro is ok, as it's defined as (-9223372036854775807LL -1)

> cat f.cpp
#include <climits>
// these guys are ok.
int min_int1 = -2147483648;
int min_int2 = INT_MIN;
// min_ll1 causes troubles, while min_ll2 is ok, because it's defined as (-
9223372036854775807LL -1)
long long int min_ll1 = -9223372036854775808LL; // 0x8000000000000000LL
long long int min_ll2 = LLONG_MIN;
> clang++ f.cpp -c
f.cpp:6:26: warning: integer literal is too large to be represented in a signed
integer type, interpreting as unsigned [-Wimplicitly-unsigned-literal]
long long int min_ll1 = -9223372036854775808LL; // 0x8000000000000000LL
                         ^
1 warning generated.
Quuxplusone commented 7 years ago

What do you think is illegitimate about this? The warning appears correct to me. Please keep in mind that unary - is an operator, not part of the literal itself.

Quuxplusone commented 7 years ago

Ouch. You are right. I was confused by missing warning for INT_MIN. I've re-read literals section in the standard and now the warning makes sense. Sorry for false alarm.