user2148758
user2148758

Reputation: 353

How much does the GCC compilers keep to the C/C++ standards?

For example, the C programming language with C99 standard supports hexadecimal floating-point literals but the C++ with C++03 standard doesn't.

I tested it, GCC recognized the hexadecimal floating literal in C++03 mode (-std=c++03) but according to the C++ standard, it shouldn't. I know, it's not a tragedy, I'm just interested in this question..

Does the GCC compilers conform to the standards? Can you recommend me a C/C++ compiler that conforms to the standards "perfectly"?

Upvotes: 2

Views: 140

Answers (2)

Jonathan Wakely
Jonathan Wakely

Reputation: 171253

The Comeau compiler, using its own libcomo standard library, is about as close to perfect C++03 support as you can get.

For C++11 Clang with libc++ and GCC with libstdc++ are both pretty good, but not perfect (yet)

Upvotes: 0

thiton
thiton

Reputation: 36049

When you give a standard to the GCC, according to the manual the

compiler will accept all programs following that standard and those using GNU extensions that do not contradict it.

If you want to ensure strict adherence to the standard, add -pedantic, which will warn about hex FP literals.

Upvotes: 5

Related Questions