Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
7650 Discussions

Bug? Binary literals are supported for old c++

Ben_Ari__Doron
Beginner
144 Views

I use this compilation lines:

icpc -std=c++98 -pedantic-errors integers.cc

To compile the following piece of code:

int i = 0b10101;
std::cout << i << std::endl;

It compiles well and works perfectly (the output is 21).
To verify that i use the correct compiler flags I add the following line

auto g () {
    return 2.3;
 }

And indeed in this case I get the expected compiler error when using the compiler flags.

Binary literals is a feature that is supposed to exist only since C++14. So why does my code of binary literals compile? Is it icpc bug?

(With g++ and same flags, it works as expected and does not compile with the binary literals)

0 Kudos
1 Reply
Viet_H_Intel
Moderator
144 Views

Seems like icpc didn't catch this case of -std=c++98.

Reply