Comment by vlovich123
2 days ago
> Anything that's not nailed down by the standard should be expected to vary between implementations.
When you have one implementations you have a standard. When you have two implementations and a standard you don’t actually have a standard in practice. You just have two implementations that kind of work similarly in most cases.
While the major compilers do a fantastic job they still frequently disagree about even “well defined” behavior because the standard was interpreted differently or different decisions were made.
> When you have two implementations and a standard you don’t actually have a standard in practice
This simply isn't true. Plenty of standardized things are interchangeable, from internet RFCs followed by zillions of players and implementations of various RFCs, medical device standards, encryption standards, weights and measures, currency codes, country codes, time zones, date and time formats, tons of file formats, compression standards, the ISO 9000 series, ASCII, testing standards, and on and on.
The poster above you is absolutely correct - if something is not in the standard, it can vary.
Lots of things have standards that are mostly interchangeable. But pretending like the implementations don't interpret standards differently and have important differences is naiive. This is doubly so for language implementations which frequently leave things as "implementation defined". Clang and GCC have intentionally made significant efforts to minimize their differences which is why it's less noticeable if you're just swapping between them (it didn't start out this way). MSVC has not made these efforts. Intel abandoned their compiler for Clang. So basically you already have MSVC & clang/GCC as dialects, ignoring more minor differences that readily exist between clang and GCC.
Compare this with languages like Zig, Rust, and Python that have 1 compiler and doesn't have any of the problems of C++ in terms of interop and not having dialects.
Java is the closest to C++ here but even there it's 1 reference implementation (OpenJDK that Oracle derives their release from) and a bunch of smaller implementations that everyone derives from. Java is aided here by the fact that the JDK code itself is shared between JVMs, the language itself is a very thin translation of code --> byte code, and the language is largely unchanging. JavaScript is also in a similar boat but they're aided by the same thing as Java - the language is super thin and has almost nothing in it with everything else deferred as browser APIs where there is this dialect problem despite the existence of standards.
HN is a censorship haven and all, but I'd like to point out just one thing:
>Compare this with languages like Zig, Rust, and Python that have 1 compiler and doesn't have any of the problems of C++ in terms of interop and not having dialects.
For Python, this is straight up just wrong.
Major implementations: CPython, PyPy, Stackless Python, MicroPython, CircuitPython, IronPython, Jython.
If you have an area where the standard is ambiguous about its requirements, then you have a bug in the standard. And hopefully you also have a report to send along to help it communicate itself more clearly.