News for hackers. Stuff that matters.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by vlovich123 on Friday August 15, 2025 @12:44PM (#44914579)
All I took away from this is how more and more complicated C++ as a language becomes to make the syntax slightly more convenient.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by saghm on Friday August 15, 2025 @02:53PM (#44916162)
I get as exasperated at C++ as anyone else, but IMO there's another takeaway here, which is that smart contracts are an absolutely terrible idea. Relying on code as the source of truth for a transaction just completely disregards the reality that code is always going to be buggy. For those who might not be aware, this is the same smart contract framework where someone accidentally killed $300 million of transactions because a function in a library for setting the wallet associated with a private key was defined as public instead of private: https://medium.com/cybermiles/i-accidentally-killed-it-and-e...

Yes, you can fix issues like this with a "hard fork" if you have a large enough consensus, but at that point, does the system of having smart contracts actually improve anything over the one where the software is downstream rather than the source of truth, or are you just replacing one form of "human intervention required" with a different but worse one?

Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by RealityVoid on Friday August 15, 2025 @04:06PM (#44916777)
As opposed to being subject to interpretation of the truth, with the courts of varying quality. My point is... everything has error bars.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by eightysixfour on Friday August 15, 2025 @07:34PM (#44918496)
It must. Things that interact with the real world need slack.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by sealeck on Friday August 15, 2025 @11:01PM (#44919736)
> with the courts of varying quality

You can usually pick the jurisdiction (e.g. many contracts are under jurisdiction of England & Wales/Switzerland/Singapore despite neither party being based there, or doing business there).

I think in general judges are quite considered, and the answers you get from courts tend to make quite a lot of sense, especially if you are aware of general legal principles and precedent.

Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by josefx on Saturday August 16, 2025 @04:47AM (#44921492)
You are still subject to courts if you use smart contracts, they change literally nothing about that.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by saghm on Saturday August 16, 2025 @04:54PM (#44926853)
The reliance on context and human intervention in our current system is a feature, not a bug. That's my entire point; if you get rid of that, you're introducing a lot of issues, and if you don't, you're throwing out a system with literal centuries of stress-testing where the flaws are legitimate but well understood to switch to one with literally no evidence to suggest that it's better.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by usmannk on Friday August 15, 2025 @02:59PM (#44916216)
This is about a language compiler bug. There are no takeaways about smart contracts here.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by saghm on Friday August 15, 2025 @04:03PM (#44916747)
It's about a compiler bug in C++ that had downstream effects in the compiler for Solidity, which is a language for developing smart contracts. Yes, every compiler can have bugs, even ones not relating to smart contracts, but that doesn't seem like a very convincing argument that we should be using compilers for more things rather than boring regular code that isn't considered to be contractual.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by tsujamin on Friday August 15, 2025 @03:08PM (#44916311)
So long as you’re writing your smart contracts with a chisel, into a stone tablet, with no compilers or assemblers in sight!
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by tkz1312 on Friday August 15, 2025 @05:36PM (#44917534)
The bug was a simple segfault and did not result in the production of invalid or incorrect code.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by saghm on Saturday August 16, 2025 @04:55PM (#44926857)
Segfaults are the lucky case when you run into undefined behavior. The unlucky case is that you just get a program doing something different than what you intended without any clear indication that something went wrong.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by charcircuit on Friday August 15, 2025 @03:09PM (#44916321)
You can fix smart contracts without a hard fork. In fact it's common practice for them to be upgradable.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by saghm on Friday August 15, 2025 @04:00PM (#44916731)
Does it fix them only going forward, or does it actually update what happened in previous transactions retroactively? If the latter, does everyone involved with any transactions using the said contract have a say in whether the upgrade occurs? I'm skeptical that this would actually be a good mechanism in general given how likely it seems that some contracts might be so widely used to essentially require a hard fork in order to upgrade retroactively, but I'm open to the idea that I might be missing something here.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by charcircuit on Friday August 15, 2025 @04:39PM (#44917018)
It only updates the code that will run. Fixing it going forward. To protect oneself against losses due to bugs people can use insurance smart contracts.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by saghm on Saturday August 16, 2025 @04:56PM (#44926873)
I guess I'm just skeptical that writing more code to try to protect against code being buggy will result in a system that works better than what we have today. Software with tests written for it still has plenty of bugs, after all.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by charcircuit on Saturday August 16, 2025 @05:01PM (#44926900)
Expecting code to be perfect and code complete the first time around is typically a losing bet.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by saghm on Saturday August 16, 2025 @08:13PM (#44927894)
I completely agree, which is why I don't think that contracts should be expressed in code in the first place. You have to spend a lot of effort up front just to reach parity with contractual systems that don't rely on code, and even if you get to that point, it's not really clear to me what benefits you'd get over what we have today.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by twoodfin on Friday August 15, 2025 @01:07PM (#44914866)
It’s less about convenient syntax and more about simplifying the construction of abstractions.

You could argue that the latter is the core drive to evolve the standard.

Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by mgaunard on Friday August 15, 2025 @02:28PM (#44915870)
Every new version of C++ (and sometimes even new versions of C++ compilers) can break code in subtle ways.

You should always do extensive testing before upgrading.

Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by reactordev on Friday August 15, 2025 @02:48PM (#44916108)
That’s the crux of the issue. People fear upgrading because of the bugs introduced by more complexity for more terse syntax.

How much longer will you suffer?

Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by mgaunard on Friday August 15, 2025 @04:07PM (#44916785)
The same is true for any software. If you care about reliability, you pin, and carefully test before upgrading.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by vlovich123 on Friday August 15, 2025 @06:14PM (#44917886)
I have not observed the same with other languages, whether that’s Java, Rust, or Swift.

And note this is about an older compiler version using an older library with a “newer” language spec (ie been around 5 years). If you use up to date toolchains there’s less of an issue. This is yet another perennial weakness in the c++ ecosystem that isn’t present in other languages because the standard committee continues to abrogate their duties here.

Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by immibis on Friday August 15, 2025 @01:25PM (#44915067)
It's not slightly, it's substantially more complicated to become substantially more convenient. The leap from C to C++ is similar to the leap from assembly code to C. As you add features, the language becomes more complex. That's just how it is.

Most languages deal with this by limiting the features they have - but not C++! (or Scala, which is like Java's C++)

Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by bri3d on Friday August 15, 2025 @01:35PM (#44915167)
This is a perfect summary of C++: substantially more complicated for substantial convenience.

Add Boost to the mix, as in this bug, and C++ becomes quite ludicrous really, but it can also combine efficiency, interoperability, and performance in a way that's quite difficult to achieve in other languages.

IMO, starting a good C++ project is an exercise in defining a specific language based on a subset of C++ more than anything else: done right, it can be a big lever, done wrong, it can be a big foot-gun.

Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by tialaramex on Friday August 15, 2025 @02:53PM (#44916161)
If we make the underlying mistake in Rust (actually I did last week for unrelated code) by defining an operator implementation as simply calling itself rather than calling some concrete implementation, the compiler warns us, this is infinite recursion which probably wasn't what you wanted.

G++ has to emit code here to recurse infinitely, so it's not as though there's no opportunity to say "Huh, that probably won't be what they meant"

Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by jcelerier on Friday August 15, 2025 @03:21PM (#44916431)
C++ compilers had warnings about infinite recursion for years now (since at least 2015 for clang)
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by tialaramex on Friday August 15, 2025 @03:56PM (#44916689)
Fair. That's actually crazy - I dug into this more and found the chosen Boost package fails tests on the chosen compiler, and so if they'd done even a cursory check to see if what they're doing could make sense there'd be red flags everywhere.

So the overall story is mostly "Our QA is garbage".

Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by saalweachter on Saturday August 16, 2025 @06:57AM (#44922142)
If it's at the "we never compile with -Wall -Werror" level of non-existent QA, I feel like that's an insult to garbage.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by tialaramex on Saturday August 16, 2025 @09:21AM (#44923171)
-Wall -Werror means that instead of being able to be used as a ratchet the set of "all" warnings in C and C++ became rusted in place. I sympathise with the instinct to write this in your compiler flags, but alas thanks to Hyrum's law this makes the future worse and so today people ask that you -Wextra and no doubt I'll eventually read of how C is fine so long as you -Wall -Wextra -Wevenmore -Wyetmore -Wandthese
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by ranger_danger on Friday August 15, 2025 @01:59PM (#44915508)
You don't have to use all the fancy new features though. Personally I just stick to C++98 for the most part, unless I really want to use auto or lambdas for some reason, then I might use 11, but I won't go higher.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by whizzter on Friday August 15, 2025 @02:36PM (#44915971)
C++ 11 with lambdas is so much nicer than 98, but even if 14, 17, 20 and 23 have been minor in comparison the accumulated changes have been radical in making what was introduced in 11 into something really useful.

Making anything remotely useful out of templates was deeply into hideous SFINAE-land (substitution-failure-is-not-an-error) leading to horrible unreadable templates during 98 (and the variable-number templates in 11 while being useful only made it explode in horrendeous hacks).

"if constexpr" from C++ 17 and forward actually makes template-expansions not too horrid. you can do template expansions that reads mostly like regular if-elseif-else clauses (and I think that was perhaps part of the impetus for Zig's comptime, starting from this point with a clean slate instead of going through regular template evolution hell).

Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by jeffbee on Friday August 15, 2025 @04:18PM (#44916869)
The horrendous hacks went away with concepts. SFINAE is dead. Spaceship operator, while perhaps not ideal from every perspective, radically simplifies the workload of implementing comparators.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by saagarjha on Friday August 15, 2025 @05:42PM (#44917580)
Assuming the thing you want actually has a concept, sure.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by majoe on Friday August 15, 2025 @06:29PM (#44918018)
You can define your own concepts. What is your point?

I haven't seen an example yet, where concepts weren't simpler and easier to read/understand than SFINAE shenanigans.

Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by jeffbee on Friday August 15, 2025 @07:19PM (#44918385)
Not only can you define concepts, it is highly entertaining and educational. You can write a concept that makes a function only available on Tuesdays, for example.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by ranger_danger on Friday August 15, 2025 @07:11PM (#44918330)
I don't use templates hardly at all, and I find the added changes in later versions to seriously complicate what I would prefer to be much simpler, for example initialization rules... so that's one of several reasons I like to stick to older C++ versions.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by addaon on Friday August 15, 2025 @09:01PM (#44919031)
C++ pre- and post- C++11 are really different languages. It’s by far the biggest break (so far in my career) in how the language is used. I’ll gladly debate the detailed trade-offs of many of the newer features, but going back to a world before rvalue references is too horrifying to consider.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by sillysaurusx on Friday August 15, 2025 @02:37PM (#44915977)
Eh, you’re probably missing out. I remember C++20 being really convenient in comparison, though I forget why.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by saalweachter on Saturday August 16, 2025 @07:03AM (#44922174)
Eyeballing C++ 20, struct initialization with .member = blah is the one that jumps out.

But also, since the referenced bug involves Boost... I also haven't used Boost in years, since most everything I was using got pulled into modern C++ versions/STLs.

So if you're using C++98 and Boost, do yourself a favor and just switch to C++17 or 20 or whatever.

Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by bdhcuidbebe on Saturday August 16, 2025 @01:06AM (#44920341)
Ah yea, why not settle with the 14 year old version?

The MAGA version.

Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by userbinator on Saturday August 16, 2025 @01:26AM (#44920447)
It becomes substantial inconvenience as soon as you need to try to figure out why something doesn't work the way you thought it should.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by wavemode on Friday August 15, 2025 @03:17PM (#44916410)
Scala has the advantage (and disadvantage) of not caring one lick about backwards compatibility. They were perfectly happy to burn it all to the ground and redo the language's syntax in v3. And even point releases of Scala frequently have breaking changes.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by seanhunter on Saturday August 16, 2025 @10:40AM (#44923859)
I respect that, but kind of lost patience with it when a new version of the compiler decided that my types were no longer decidable in code that hadn’t been touched for years. I tried for about 5 mins to fix it and then just thought “It’s not me, it’s you” and put scala down never to pick it up again.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by vlovich123 on Friday August 15, 2025 @06:39PM (#44918119)
I have observed significantly better useful features from Rust or Swift (or Scala) without horribly complicating the language like C++ does. More importantly, they migrate existing codebases and have migration tools instead of breaking old versions of syntax. Rust’s is the most ambitious here letting you mix match editions of the language within a single binary.
Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by DokDidhuAd on Friday August 15, 2025 @07:29PM (#44918461)
Yeah, C++ is just batshit insane.

> In C++, when you write an expression like a == b, the compiler chooses among available operator== implementations by comparing their match quality. A member function like a.operator==(b) usually has higher priority than a non-member function like operator==(a, b) — unless the types differ too much or are ambiguous.

This is the largest foot-bazooka ever. The point of operator overloading is that the operator in a given expression look natural, feel natural, and behave naturally (= function intuitively). If you have multiple possible operators that could apply, for the same syntax, then you're in a worse position than you originally were -- where an operator either did one particular thing, or didn't apply at all. What operator overloading does in practice is introduce ambiguity. Which is self-defeating. You are better off with C-style, named, non-overloaded functions.

You will never find this crap in actual math. "match quality" my ass.

Re:Compiler Bug Causes Compiler Bug: How a 12-Year-Old G++ B... by maccard on Friday August 15, 2025 @09:09PM (#44919087)
> You will never find this crap in actual math

Sure you do. What’s 6/2(1+2)