Live data from Hacker News

Linus Torvalds on aliasing

yodaiken.com

241–250 of 284 posts

Re: Linus Torvalds on aliasing

#241
post #208

Earlier quoted context omitted.

Swearing in general doesn't damage morale, but swearing at and verbally abusing someone does very much so. That's exactly the kind of treatment that would lead me, if I were a developer, to walk away from the project. In fact, here's an edit which gets his point over in less words, and more clearly: "Honestly, this looks questionable to me. [U]sing a union to do type punning is the traditional AND STANDARD way to do…

And that's the reason PR exists. To translate text written by "knowledgeable person, who writes in not acceptable to everyone language" into "language acceptable to everyone". This also leads to no more direct contact between public and those people and the eternal cries of "we only get PR speak!!" The chances that you get to hear things from the source and never hear things in a way you don't like is almost zero. Yo…

PR gives things a nicer wording, but they also push unjustified implications and flat-out lies. When people object to PR-speak, it's usually the latter. Or that an apology doesn't seem to actually be sorry or trying to fix anything. They're rarely objecting that the language is a bit less harsh.

Re: Linus Torvalds on aliasing

#242

Earlier quoted context omitted.

Type punning through a union is allowed, buy you have to be careful so the compiler can see the union. union { int i; float f; } u; You can't safely call a function with pointers to the members like func(&u.i, &u.f), because when func was compiled, the compiler couldn't know that the arguments are pointers to union members. This sort of thing scares me, because what the compiler can "see" isn't well defined. Is it ok…

Assuming we're talking C, not C++, the compiler doesn't need to know that the arguments are pointers to union members, because the union members are all aligned with the union itself and have the same address. So &u.f is not some magic special pointer, it's the address of a float. So is (float *)&u. The example in the standard I think you're referring to relates to a special guarantee made about unions of structs tha…

The compiler and standard are both full of contradictory, useless, and counter-productive rules on aliasing. But both gcc and clang now support _may_alias_ and -fno-strict-aliasing without which they would have made the language completely unusable.

Re: Linus Torvalds on aliasing

#244

Earlier quoted context omitted.

This does technically require that a union of those structs exists, even though it is not used. I don't know of any compiler for which this actually makes a difference though.

Ah, I misunderstood the context, you are right to clarify this.

I checked and we actually have a give union for everything. I didn't mention it because I accidentally got rid of it when simplifying my question (the original is full of macros).

Looks like we are in the clear! :)

Re: Linus Torvalds on aliasing

#245

Earlier quoted context omitted.

I didn't bring the military up to say that it's an authority on proper conduct. Rather, I'm saying that EVEN in the military, with some of the most insensitive people around, swearing indicates lack of self-control and situational awareness.

You haven't spent much time with the military have you? Swearing is a delicate and beautiful art form, more expressive and nuanced that the dry words of HN.

Eight years, which included serving as a PSG then joining the dark side.

Obviously swearing is a big thing, but not when leading. You'll have exceptions with some of the line units of course, but that's a culture that won't change.

If I saw one of my squad leaders cursing at someone for doing something dumb, then I'd know that supposed leader just failed that Soldier. At ease those emotions, get your point across, and hold them accountable. If you can't do that without throwing a hissy fit, take off those stripes.

Re: Linus Torvalds on aliasing

#246
post #181

Earlier quoted context omitted.

> As a northern European I find it not only comfortable that Linus runs Linux, but I would be less comfortable if it was another American smile in face pretend to be your friend but be shady as fuck attitude that you guys seem to confuse for 'professionalism'. This is a false dichotomy. Most of what Linus says would run foul of HN's guidelines - which I'll paraphrase here as "don't call someone an asshole before maki…

When somebody speaks their mind, everybody around them knows where they stand. I doubt there is difference between about how often people resent other people around the world. But I do consider it more humane if resentment isn't hidden under the surface. It's easier to trust Linus than a tactfull politician. That should make us all think.

> It's easier to trust Linus than a tactfull politician. That should make us all think.

I can kinda see where you're going with this, ie. the idea that knowing what someone is thinking means you can trust them... but I disagree.

To my mind verbal abuse doesn't mean they're speaking their mind, it means they've lost control.

Based on these blow-ups I'd certainly question trusting Torvalds in any high stakes situation that required tact under pressure... which I would expect to happen frequently when running a country.

Re: Linus Torvalds on aliasing

#247
post #124

Earlier quoted context omitted.

When it comes to being oversensitive needy little things there is no true Scottsman. As a northern European I find it not only comfortable that Linus runs Linux, but I would be less comfortable if it was another American smile in face pretend to be your friend but be shady as fuck attitude that you guys seem to confuse for 'professionalism'. So let's chalk this to cultural differences. We wouldn't hire someone like y…

> As a northern European I find it not only comfortable that Linus runs Linux, but I would be less comfortable if it was another American smile in face pretend to be your friend but be shady as fuck attitude that you guys seem to confuse for 'professionalism'. This is a false dichotomy. Most of what Linus says would run foul of HN's guidelines - which I'll paraphrase here as "don't call someone an asshole before maki…

He didn't call anyone an asshole. His insults were reserved for the arguments and the standard itself.

Re: Linus Torvalds on aliasing

#248
post #117
post #34

To me, this rant seems more directed at C standards people than the guy he sent it to. That doesn't excuse his vitriol, but I hope people will read between the lines. Sometimes people forget that C was created for writing operating systems. They get in their mind that C is all about high-performance, and that making it competitive with FORTRAN is the way to go. I understand that, but it's not what C was created for.…

The problem is in how the gcc (and to some extent clang) maintainers read the standard. If the C standard says: the following construct is undefined, then as a compiler writer you have two options: you try to figure out what is sensible in this context, or you do something crazy that conforms to a literal interpretation. For operating system code, you want the compiler to something sensible. Life is already hard enou…

> If the C standard says: the following construct is undefined, then as a compiler writer you have two options: you try to figure out what is sensible in this context, or you do something crazy that conforms to a literal interpretation.

Not exactly. Rather, the compiler is not constrained by any particular behavior of the construct which is said to be undefined. So if there is an optimization that changes the meaning of the undefined construct, it's all fair game, because the construct was not defined in the first place.

Re: Linus Torvalds on aliasing

#249

Earlier quoted context omitted.

Assuming we're talking C, not C++, the compiler doesn't need to know that the arguments are pointers to union members, because the union members are all aligned with the union itself and have the same address. So &u.f is not some magic special pointer, it's the address of a float. So is (float *)&u. The example in the standard I think you're referring to relates to a special guarantee made about unions of structs tha…

The func can be implemented like this: float func(int *i, float *f) { *i = 42; return *f; } Since the compiler assumes that the pointers i and f do not alias, it has a right to generate the code that is equivalent to: float func(int *i, float *f) { float result = *f; *i = 42; return result; } But this will change the result of the function. So in practice if you want to do type punning using unions, the compiler must…

Sure, by not accessing the members through the union type you lose the information the compiler needs to relax strict aliasing assumptions for union access. It's a potential footgun, but IMO only with careful aiming. It's also not strictly related to union member pointers but applies generally to aliased pointers.

Re: Linus Torvalds on aliasing

#250
post #180

Earlier quoted context omitted.

Swearing doesn't damage morale. Many soccer coaches and inspiring pep talks contain swear words. It's a style figure. Tact can be very usefull in small teams where trust and coordination is important. For large projects, with thousands of stake holders the bar to participate in a conversation should be high. As we both say in Holland: we are not made of sugar. But go read Linus rant now and ask yourself: would this r…

I didn't say people can't confront each other or even swear at each other. My point is that Linus is swearing at someone who made a contribution to a project. What sense is there in saying the following to people other than signifying that you don't respect them: "...when you are a f*cking moron" "Andy, what is the background for trying to push this idiocy?" Note that I only called the other swearing in his text chil…

I don't believe that you've had to argue this far to defend your point. Treating others as you would like to be treated is the golden rule of society.

When I play games like Rocket League, a game where you depend on your teammates, I rarely say anything if people play badly. Others will say things to me if I play badly and that sometimes makes me play even worse depending on my mood. Sometimes I play worse because they actually made me care less and sometimes I play worse on purpose because they were a real asshole and they deserve a loss.

It's pretty obvious that antagonizing and disparaging your teammates is generally a bad plan anywhere.

Post reply on HN