Neither GCC nor Clang are compliant with standard C++ (sebsite.pw)

46 points by birdculture 20 hours ago

kloop 18 hours ago

Give how default gcc and clang are, along with the recommendation to update the standard instead of gcc and clang, it sounds like the standard is noncompliant with standard C++

Standard in the sense of commonly used or supplied

dataflow 11 hours ago

The blog post basically said exactly this:

> IMO the blame here doesn't lie on gcc or clang; it lies on the standard. that is, the standard is wrong and should be updated to make this implementation-defined.

ksec 17 hours ago

Yes. And Hasn't this always been the case? Before GCC and Clang took over everything there were plenty of C / C++ compilers from Intel, Visual C++ etc.

pizlonator 17 hours ago

Yes

The only truth is shipping code

Specs are secondary

pmkary 17 hours ago

I laughed so hard at this....

Fudgel 14 hours ago

dataflow 11 hours ago

> gcc and clang can't change their behavior because that would be a breaking ABI change

It's an API change. Breaking source code is generally an even bigger deal than breaking binary compatibility.

Joker_vD 6 hours ago

Eh, both are about the same? With the source-level API changes, you can patch the source code or, you know, just keep using the already existing binaries, or keep using the old compilers. But if you break ABI, you can't keep using those already existing binaries, you need to start upgrading in bulk. Using the new compilers. That also probably have some source-level API changes. Oh dear.

ch_123 18 hours ago

Hot take: I feel like a lot of the original value of language standards was to unite multiple proprietary implementations of compilers/runtimes/etc. from different vendors, each of which had incentives to add non standard features to attract customers and keep them locked in. This has been significantly diminished in the last decade or two now that most languages have high quality open source implementations - now you can simply port your compiler of choice to the platform you need.

ameliaquining 17 hours ago

I half-agree with this. People occasionally argue that, e.g., Rust won't be suitable for production use until it has two fully independent mature implementations, and I consider this a silly requirement that doesn't serve any real purpose. On the other hand, once multiple separate implementations are already in widespread use, there's immense value in working out a least common denominator of language features and standard library APIs that work everywhere, so that library authors can write portable code that users of any implementation can depend on.

Of course, it's always possible that the standardization body doesn't in practice do a very good job, as seems to maybe be the case with the C++ committee. Also, I'm only talking here about technical considerations, not governance ones.

jamesfinlayson 13 hours ago

> On the other hand, once multiple separate implementations are already in widespread use, there's immense value in working out a least common denominator of language features and standard library APIs that work everywhere

Yeah this was what I thought. I remember Valve Software wrote a paper about cross platform development and said it was useful compiling with Visual C++ and gcc to shake out any iffy syntax that worked in one but not the other. Of course with performance-critical code and code that needs to run on consoles as well there will always be platform-specific stuff, but if you can get 99% of the code working across multiple compilers that's pretty good.

jdw64 18 hours ago

But looking at this, it seems like something similar happened 12 years ago[1]. Why hasn't it been changed?

[1]https://cplusplus.github.io/CWG/issues/1555.html

gregdaniels421 18 hours ago

The working group said bring us a paper with the exact proposal, I haven't seen an update where someone did.

jdw64 18 hours ago

Is it because the impact of the change is too big? I mean, is that why it's hard to submit a proposal?

112233 8 hours ago

tester756 18 hours ago

leecommamichael 18 hours ago

If you're starting a new project and can afford it, please for the love of the children, use a different systems language. In so many ways Odin, Rust, Zig, whatever are better. There will be growing pains with respect to collective knowledge and performance, but they are surmountable.

Context: I am a programmer and educator. I am so tired of informing people of these minutiae.

lallysingh 16 hours ago

I've tried it, and no. Honestly C++ gets so many complaints partially because so many people use it. It deserves a lot of it.

I just finished my work on a 2.5 yr rust project that was very low-level. The problems I had with it were that the language and library designs will always be behind the current state of the art in performance. Hardware and systems APIs change quickly, and they can shift the optimal design decisions easily for different workloads. E.g. chiplets on your CPUs can change where you want to put your io_urings, their workers, and any relevant sq_poll threads. Your NIC's DMA/TLS facilities can change your memory pool policies - do you want zero-copy APIs, or is the copy required anyways because of all the CPU-local work you have to do? Do you preallocate and feed giant buffers to register with the io_uring, or do you need to share your memory pool with the rest of the application? Do you use a single mutex for the pool, a hierarchy between thread-local and global? Do you also use a chiplet-local allocator?

What's nice about C++ is that your fight isn't against the language and runtime. They don't care what your situation is. They'll work. You do have to assemble it, and other languages make some assemblies a lot easier to do.

Yes Rust and its libraries are getting better. But so's C++.

112233 8 hours ago

On embedded, your fight totally is against language and runtime. Since you cannot gave conformant freestanding C++ without exceptions, rtti and most of STL, "using c++" on embedded always turns into "using gcc" or "using clang" — their mutually compatible, but completely standards non-conformant extensions that make writing for embedded reasonable to even attempt. At that point, is the language still c++?

Meanwhile, both rust and zig will gladly compile your standalone function into standalone binary.

leecommamichael 15 hours ago

These are legitimate complaints, and I meant for "if you can afford it" to do a lot of lifting in my first comment.

tsimionescu 18 hours ago

Systems programming is very much about minutiae, to a great extent. And this particular detail will affect any systems language, one way or another. Every language has to decide if the calling convention is part of the function signature or not, and every systems language then has to decide whether it allows C functions with the same name as native functions or not. The C++ standard decided to allow this, which actual C++ compiler implementers decided to ignore for whatever reason, but that's just a bug, of which, again, you'll find many others if you actually do systems programming.

I'll also note that "Odin, Rust, Zig" is a weird enumeration - neither Zig nor Odin are anywhere near being a realistic option for a new complete system. Odin is so obscure it doesn't even have a Wikipedia page. Zig is still pre-1.0 and often makes breaking changes to core libraries.

Joker_vD 6 hours ago

> Every language has to decide if the calling convention is part of the function signature or not

Well, of course it is. If you get the calling convention wrong, then you can't actually reliably call the function. I've seen this in e.g. Win32 — pass the function with the wrong calling convention as your callback, and it will dutifully thrash your stack.

The only other option is "pretend that there is only single calling convention that everyone uses" which is apparently somewhat works on platforms that are not 32-bit x86, but only mostly.

> The C++ standard decided to allow this,

Decided to prohibit, actually.

> which actual C++ compiler implementers decided to ignore for whatever reason,

Because it's UB anyway so why bother detecting it, and it mostly works most of the time when people use it, so again, why bother prohibiting it? No promises on keeping things working in perpetuity, of course.

jstimpfle 17 hours ago

To be fair, Odin _had_ a Wikipedia page and it has been removed because of... people with whatever interests. But I'm still agreeing with your general point. I use C/C++ because it seems to be the least friction option to me overall, and I don't want to deal with language but simply focus on my actual compute problem. (Given that, I spend an unreasonable amount of time in silly fights about language).

tsimionescu 16 hours ago

leecommamichael 17 hours ago

I'm talking about design flaws, not engineering details. I would appreciate if you would respond in spirit. I do think the list I gave is odd, and it is so because it's kind of a mashup of recent pop-culture things. I'm literally just appealing to people to attempt to use something designed with the benefit of 50 years of hindsight. Why am I being downvoted?

tsimionescu 16 hours ago

lallysingh 16 hours ago

edoceo 16 hours ago

lokar 17 hours ago

t0mpr1c3 17 hours ago

Lindy's Law says C will be around longer than any of that lot. Although I wouldn't bet against Rust now that it's used for Linux drivers.

bee_rider 17 hours ago

C will outlive all of us.

C++… I don’t know it well. But I’ve heard there are a lot of different dialects, to the point where it is possible that two C++ programmers might be writing in essentially different languages. How “old” is the language, in that case?

t0mpr1c3 17 hours ago

pjmlp 4 hours ago

AlotOfReading 17 hours ago

pjmlp 4 hours ago

While both C and Rust compiler infrastructure used by Linux drivers is written in C++.

undefined 16 hours ago

[deleted]

jjmarr 18 hours ago

Unfortunately I'm a GPU programmer. C++-based CUDA/HIP is still the standard regardless of how much people would rather use Rust to program GPUs.

tadfisher 17 hours ago

Who is stopping you? Is it an employment concern?

t0mpr1c3 17 hours ago

feverzsj 18 hours ago

Only if you don't code for living.

wyattblue 17 hours ago

Consider Nim too!

undefined 18 hours ago

[deleted]

undefined 7 hours ago

[deleted]

ndesaulniers 18 hours ago

Shrug, then write a defect report?

froh 18 hours ago

on the standard? or the compilers? or both?

hmxrye 18 hours ago

[flagged]