Live data from Hacker News

Linus Torvalds on aliasing

yodaiken.com

161–170 of 284 posts

Re: Linus Torvalds on aliasing

#162
post #78

Earlier quoted context omitted.

> Linus has done some (okay, lots of) wonderful stuff. However, his attitude here is pretty extreme. Being incredibly rude, then proceeding to merge said pull request. He already writes that he's OK with the code ("can live with it") -- he's against the reasoning that accompanies it.

Good code or not, if he doesn't agree with the reason to merge it, why merge it?

Because the code is OK, but the _rationals_ in the commit message (union aliasing is bad) are not.

This is for history. If someone, later, say: "We should use union aliasing to fix this", someone would argue "No, we shouldn't because we already states _there_ that union aliasing is bad".

You can't consider a such amount of code like the kernel one without its commit history.

Here Linus explain why union aliasing is not "bad" per see, but considered "bad" because the C standard say so and he clearly explain standards are not holy book and compiler implementation is as important (something he always states).

Re: Linus Torvalds on aliasing

#163

I would go out of my way to avoid people who communicate like this with me. People put time and energy in making software better, at least in their own eyes, for others and then they get textually abused like this by someone who has his fame to protect himself with. He also does no service to his own arguments by peppering them with childish swearing because things like "So standards are not some kind of holy book th…

Another moral indignation post at the top of the propaganda channel. Hint: Perhaps no one wants to communicate with you, too.

Re: Linus Torvalds on aliasing

#164
post #41

I work with a codebase that implements a sort of OO inheritance in C. It looks like this: #define BASE_FIELDS int a; int b; int c; struct Base { BASE_FIELDS }; struct Derived1 { BASE_FIELDS int d; int e; }; struct Derived2 { BASE_FIELDS int f; int g; }; Then, it has lots of code that accesses Derived objects through a `Base*`, with ->a and so on. Is this against the standard C aliasing rules? If so, how would this ne…

That is well-defined. "One special guarantee is made in order to simplify the use of unions: if a union contains several structures that share a common initial sequence (see below), and if the union object currently contains one of these structures, it is permitted to inspect the common initial part of any of them anywhere that a declaration of the complete type of the union is visible. Two structures share a common…

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.

Re: Linus Torvalds on aliasing

#165
post #124

I would go out of my way to avoid people who communicate like this with me. People put time and energy in making software better, at least in their own eyes, for others and then they get textually abused like this by someone who has his fame to protect himself with. He also does no service to his own arguments by peppering them with childish swearing because things like "So standards are not some kind of holy book th…

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…

Northern European checking in here. I feel super uncomfortable with this communication style. Don't think this is reflective of cultural differences, so much as it is personal preference.

Re: Linus Torvalds on aliasing

#166
post #93
post #88

Earlier quoted context omitted.

>C was created for writing operating systems That doesn't properly justify C's minefield around aliasing and type punning in general. It's UB galore. Thing is, whenever you're writing low level code that's tied to hardware in my experience you very often end up having to pun your types to match hardware constraints, and at this point the C standard basically says "lol good luck with that bro". I'm not a programming l…

>at the very least C should make reading from a different union member than was last written to "implementation defined" That's how it is :) The standard even describes union behavior as "type punning". I don't know if C++ allows it though.

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 if func is in the same file? Probably not. How about if I don't send the pointers to an other function and just use them locally? Probably ok, but I wouldn't trust it. If you want to type pun with a union, make sure to always access the members through the union, not with direct pointers.

The only method of type punning I 100% trust is memcpy, and if you get lucky the compiler might optimize away the overhead for you.

Re: Linus Torvalds on aliasing

#167
post #150

Earlier quoted context omitted.

As another Northern European I disassociate myself from your comment. Yes, there are cultural differences between the US and Europe. No, that doesn't mean that Europe agrees with your opinion on what constitutes acceptable behaviour in the software community. You do not speak for us.

There is no true Northern European.

There's an honest scottsman though. Ha.

I'm sure the difference is due to lattitude. A little bit of getting heated is ill advised in the scorching sun.

Re: Linus Torvalds on aliasing

#168
post #124

I would go out of my way to avoid people who communicate like this with me. People put time and energy in making software better, at least in their own eyes, for others and then they get textually abused like this by someone who has his fame to protect himself with. He also does no service to his own arguments by peppering them with childish swearing because things like "So standards are not some kind of holy book th…

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 making your real point", but that doesn't mean that everyone on HN is a 'smile in face pretend to be your friend but be shady as fuck'.

Re: Linus Torvalds on aliasing

#169
post #124

I would go out of my way to avoid people who communicate like this with me. People put time and energy in making software better, at least in their own eyes, for others and then they get textually abused like this by someone who has his fame to protect himself with. He also does no service to his own arguments by peppering them with childish swearing because things like "So standards are not some kind of holy book th…

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…

What nonsense. I am Dutch and live in the Netherlands, we are very direct and take little to no heed to hierarchy.

I never said that Linus should be fake friendly. I am saying that swearing does damage to moral and the power of his arguments.

Also, Steve Jobs was a notorious asshole and he is revered in the US despite this. There are countless other examples of CEOs and managers who are more than unfriendly in the US who are looked at as examples of how one should behave to be 'professional'.

Your being 'northern European' has nothing to do with any of what we are talking about. Maybe you can chalk your reaction to your apparent false sense of superiority over friendliness and, it seems, Americans.

Re: Linus Torvalds on aliasing

#170

raises hand I would love to be able to contribute to the linux kernel one day. But I'm unlikely to ever become part of the community when its leader behaves like this.

I don't think you have to worry here. Even as a kernel contributor, you'd likely never interact directly with Linus.
Post reply on HN