1

My VC2017 compiler is showing this behavior, can someone explain me what is going on?:

long long testLLSigned0 = LLONG_MIN; // OK, equal to -922129006921510580
long long testLLSigned1 = -922129006921510580i64‬; // Error, invalid suffix i64 on integer constant
long long testLLSigned2 = -922337203685477580i64; // OK!
long long testLLSigned3 = -922337203685477580LL; // OK!
long long testLLSigned4 = -‭62129006921510911‬LL; // Error, use of undeclared identifier ‭62129006921510911‬LL
long long testLLSigned5 = -‭62129006921510911i64‬; // Error, use of undeclared identifier ‭62129006921510911i64
jaques-sam
  • 2,578
  • 1
  • 26
  • 24
  • 1
    Unicode Character 'LEFT-TO-RIGHT OVERRIDE' (U+202D) is causing the "number" to be an identifier. – Eljay Feb 04 '19 at 14:38
  • 2
    Related: https://stackoverflow.com/questions/45469214/why-does-the-most-negative-int-value-cause-an-error-about-ambiguous-function-ove/45469321#45469321 The literal `-922129006921510580` is not the same as the value `-922129006921510580`. – NathanOliver Feb 04 '19 at 14:41
  • @Eljay, thanks for your answer, never heard about it. How do I solve this? – jaques-sam Feb 04 '19 at 14:41
  • I don't know how to solve that in VC2017. I don't use VC2017, I use Vim. – Eljay Feb 04 '19 at 14:44
  • Okay, but Vim is not a compiler :-) you probably mean g++. I try it right away on g++ – jaques-sam Feb 04 '19 at 14:53
  • 1
    @DrumM changing the compiler (probably) won't help. You need to edit the file and remove the unicode control character. – eerorika Feb 04 '19 at 14:57
  • try this: `long long testLLSigned1 = -922129006921510580i64; long long testLLSigned2 = -922337203685477580i64; long long testLLSigned3 = -922337203685477580LL; long long testLLSigned4 = -62129006921510911LL; long long testLLSigned5 = -62129006921510911i64;` **I only removed unicode characters** – user1810087 Feb 04 '19 at 15:00
  • Indeed, with g++ I got "error: stray '\342'". It was even copied in this text. When I removed all of them I only got the following error: "unable to find numeric literal operator ‘operator""i64’" So this means, LL works. – jaques-sam Feb 04 '19 at 15:02
  • 2
    From [microsoft docs](https://learn.microsoft.com/en-us/cpp/cpp/numeric-boolean-and-pointer-literals-cpp?view=vs-2017): [...]`The i64 suffix is still supported but should be avoided because it is specific to Microsoft and is not portable.`[...] – user1810087 Feb 04 '19 at 15:05
  • Wow, thanks all of you guys. I try to formalize it in an answer. The biggest reason of this failure is due to copying values from the Windows Calculator(!!) (head against the wall...) – jaques-sam Feb 04 '19 at 15:09

1 Answers1

0

Thanks to Eljay, NathanOliver, eerorika & user1810087, I solved it.

The biggest reason the code didn't compile was due to copying the calculated values from the Windows calculator (!) into any modern editor (!). The value 62129006921510911 was copied inside the editor with invisible unicode characters! The result when pasted in vim showed us: -<202d>62129006921510911<202c>LL

Side note: use the LL syntax, the i64 syntax is specific to Microsoft and is not portable.

jaques-sam
  • 2,578
  • 1
  • 26
  • 24
  • 1
    see [How to stop Windows 10 Calculator from enclosing copied text in 202D and 202C Unicode characters?](https://superuser.com/q/1361155/241386) – phuclv Feb 04 '19 at 16:11