Hacker Newsnew | past | comments | ask | show | jobs | submit | deschutes's commentslogin

It sounds like std::atomic_ref<T>::{load,store}(relaxed) to me. 1. ad-hoc atomicity with ref 2. no ordering

https://godbolt.org/z/4h893P7hG


I believe that lets the compiler reorder the accesses. So this would be fine for my second example but it would be broken for my first example.

({READ,WRITE}_ONCE() only lets the compiler reorder the accesses if they happen in the same C statement).

I think C++ doesn't have an equivalent because it just doesn't make sense as a primitive in very many environments.


You cannot use the rust standard library in environments where arbitrary allocations may fail but neither can you use the STL. The difference is the rust standard library doesn't pretend that it has some reasonable way to deal with allocation failure. std::bad_alloc is mainly a parlor trick used to manufacture the idea that copy and move fallibility are reasonable things.

I wouldn't wager a nickel on someone's life if it depended on embedded STL usage.


You are correct, it does not affect the lifetime of the pointed object (pointee).

But a shared_ptr manages at least 3 things: control block lifetime, pointee lifetime, and the lifetime of the underlying storage. The weak pointer shares ownership of the control block but not the pointee. As I understand this is because the weak_ptr needs to modify the control block to try and lock the pointer and to do so it must ensure the control block's lifetime has not ended. (It manages the control blocks lifetime by maintaining a weak count in the control block but that is not really why it shares ownership.)

As a bonus trivia, make_shared uses a single allocation for both the control block and the owned object's storage. In this case weak pointers share ownership of the allocation for the pointee in addition to the control block itself. This is viewed as an optimization except in the case where weak pointers may significantly outlive the pointee and you think the "leaked" memory is significant.


Average citizen on receipt of news that swiss business is impaired


If you squint hard enough, any potentially allocating function is fallible. This observation has motivated decades of pointless standards work defending against copy or initialization failure and is valuable to the people who participate in standardization for that reason alone.

For practitioners it serves mainly as a pointless gotcha. In safety critical domains the batteries that come with c++ are useless and so while they are right to observe this would be a major problem there they offer no real relief.


Assuming memory is infinite for the purposes of a program is a very reasonable assumption for the vast majority of programs. In the rare contexts where you need to deal with the allocation failure it comes at a great engineering cost.

It's not really what this is about IMV. The vast majority of unrecoverable errors are simply bugs.

A context free example many will be familiar with is a deadlock condition. The programmer's mental model of the program was incomplete or they were otherwise ignorant. You can't statically eliminate deadlocks in an arbitrary program without introducing more expensive problems. In practice programmers employ a variety of heuristics to avoid them and just fix the bugs when they are detected.


Deadlocks also don’t result in panics in most environments. The problem isn’t so much bugs - those can be found and fixed. The problem is more that no_panic in most languages implies no_alloc, and that eliminates most useful code


Trying to apply heuristics like patterns to this problem is attacking the wrong thing. It boils down to a lack of belonging, trust and motivation of reviewers to do the right thing. Absentee leadership not holding engineers accountable for their inaction or slow walking of reviews being the enabler.

This kind of dysfunction happens more often on teams with incompetent people in control but sometimes temporarily happens on otherwise high functioning teams when multiple people are fighting over philosophical control of the project.


This is exactly the kind of scenario that the foreign corrupt practices act identifies as a crime. It would be kind of ironic if it wasnt recognized as a crime in the US.


The law is explicitly not what you imagine might make sense. The US government spent millions of dollars pursuing this and went with "honest services fraud" based on Amazons code of conduct which it then admitted this was incorrect.


Be that as it may, from cursory research, there is a body of US law on these kinds of practices under the term "commercial bribery". I can't speak to the legal details at all but this doesn't seem to be a case of an honest person getting mixed up in the legal system. Rather the opposite in my view.

https://en.m.wikipedia.org/wiki/Commercial_bribery


Author is untrustworthy and misrepresenting the actual details of the purported misdeeds if the sources cited in this thread are accurate.

Whether or not there is some legal argument that he didn't violate his employment contract anyone would recognize the conflict of interest at the heart of those transactions as fraud. Seems like the feds or Amazon just bungled the case.

This is funny to juxtapose with Neil Gorsuch giving accounts of honest people getting tied up in criminal cases or byzantine regulations for reasonable behavior. Hard to escape the conclusion the system is tuned to reward those with resources rather than find justice.


> anyone would recognize the conflict of interest at the heart of those transactions as fraud

Thankfully we have the law and contracts to save us from this kind of sentiment.


It may be obvious but rarely is it the focus of public discourse on drug companies. Basically the only thing that gets discussed is the apparent naked greed of drug research companies. Frankly it's a miracle that we have private companies bringing novel and life changing drugs to market, and the ability to make obscene profits off these massively speculative investments is probably the main reason.

That's not to dismiss criticism of them, but to me it's obvious, especially if you take a slightly longer view that these companies are in fact making lives better.

The real estate market is a much better example of the harmful effects of terminal greed. Unfortunately so much of the population is in on it now nobody has the fucking balls to stop the music.


I don't think it's even obvious/common knowledge in public discourse, to be honest. (Case in point: this Guardian article doesn't mention it at all, only mentioning the cost of materials and manufacturing.)

To some extent it may not even matter, since the effects of (negative) public opinion are tangible regardless of whether those opinions are fully informed of all the facts. (And even as someone who's aware of a slightly above-average number of facts, my own opinion skews pretty negative.) God knows these companies aren't in the red, trials or no trials; most consumers are just gonna look at the record profits, then back at their pharmacy bill, and go "Hey, wait a minute..."


> this Guardian article doesn't mention R&D at all

This pisses me off so much. Journalists are supposed to do thorough research so they can accurately inform the public. Instead, we see articles like this. How can we have a thoughtful discussion about serious issues when the general public is so misinformed?

> God knows these companies aren't in the red, trials or no trials

Hmmm, I'm not sure. Here's a summary of the finances of the global pharma industry: https://www.ispor.org/docs/default-source/euro2023/poster-is... Note that 55% of the companies made a profit, and the other 45% lost money.

The average profit margin was 20%. On one hand, that's larger than most industries. On the other hand, even if pharma profits were completely eliminated, drugs would only be 20% cheaper...


I always just assumed it’s not part of the discourse because everybody with an interest in the topic already knows. Articles about NVIDIA don’t mention that computers use electricity.

This article is horribly disingenuous and slanted. You could write it about any life saving drug that’s still in patent window. “Pharma company has 99.9% margins while people die unnecessarily” is just business as usual and it sounds maximally evil to phrase it that way and skip the fact that the alternative is no lives saved at all.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: