Live data from Hacker News

Linus Torvalds on aliasing

yodaiken.com

251–260 of 284 posts

Re: Linus Torvalds on aliasing

#251
post #216
post #80

Earlier quoted context omitted.

Android kernels are built with Clang. So really it's just missing support for MSVC, for obvious reasons.

For now, at least [1][2]. See the rest of that thread.. llvm guys really don't want asm goto, and kernel really wants it. [1] https://lkml.org/lkml/2018/2/14/724 [2] https://lkml.org/lkml/2018/2/14/157

Well, yeah, that's what the other commentators here misunderstand. Sure the kernel is C, but a non-optional part is assembly in various forms that obviously is not standardized between compilers. So it takes effort to support kernel building. Google paid up and made that happen.

Re: Linus Torvalds on aliasing

#252
post #117

Earlier quoted context omitted.

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…

That's exactly the problem. Somewhere a programmer working on a compiler is coding an optimization that make a program run faster, but gives a different result from what the writer of the program intended.

That's only useful if you only care about the total run time of the program and not about what it is trying to achieve.

Re: Linus Torvalds on aliasing

#253
post #71

Earlier quoted context omitted.

I'll critique his prose on efficiency grounds. He wastes many words making a point.

Let's stop policing speech, alright? You can use as many words as you want to express your views. I personally would not use the same words he might use, but let's not be hypocrites and say that none of us have written an angry or frustrated response to something that we think is stupid and just plain wrong.

I did use as many words as I wanted.

You can take as many steps as you want to get to the mailbox too. And you'll be taking more steps if you detour to go sniff dog shit. Going in a straight line solves two problems - it's faster and it smells better.

Re: Linus Torvalds on aliasing

#254
post #238

Earlier quoted context omitted.

What part of the standard should I read to come to the conclusion that type punning with unions is undefined behavior? C99 and C11 both explicitly mention that it's not, but maybe you're talking C89/C90? IMO there are 4 highly relevant paragraphs in C99: 6.2.6.1: When a value is stored in an object of structure or union type, including in a member object, the bytes of the object representation that correspond to any…

I think the clang and gcc contributors consider all this in combination with “strict aliasing” and “type” consistency attitude effectively if you just wrote a double to a union member, you can’t expect that reading integer from the same union has any meaning at all so they optimized that away “per standard”. To come to that, it’s not what is explicitly written when you do a keyword search for “union” but what is not…

> if you just wrote a double to a union member, you can’t expect that reading integer from the same union has any meaning at all so they optimized that away “per standard”.

gcc 4.9.2 for sure does not (-O3 -fstrict-aliasing). Not sure what clang does, but I'd be surprised if it ignores the standard. The standard makes it pretty clear what meaning it will have. Sure, gcc and clang maintainers may seem to read the standards like a lawyer looking to void a contract, but in this case it is actually very clear what they should do.

> what is not said that it “must work” in spite of other “must work” and “undefined” standard statements.

The standard makes it clear how to deal with the semantics: "In the abstract machine, all expressions are evaluated as specified by the semantics. An actual implementation need not evaluate part of an expression if it can deduce that its value is not used and that no needed side effects are produced (including any caused by calling a function or accessing a volatile object)." Only constraints directly use "shall"/"shall not" type language, but the expressions should still be evaluated as specified by the semantics.

Re: Linus Torvalds on aliasing

#255

Kind of sad that a person as intelligent as him can get to his age and still not realise that talking to people that way is at best highly ineffective and at worst will make them actively hostile towards you. That's not to mention rude and mean-spirited.

I just don't see it. He is frustrated with the standard being wrong, no personal insult or anything.

Re: Linus Torvalds on aliasing

#256

Kind of sad that a person as intelligent as him can get to his age and still not realise that talking to people that way is at best highly ineffective and at worst will make them actively hostile towards you. That's not to mention rude and mean-spirited.

Linus ineffective? He's one of the most successful project leaders, he does not even program that much himself now.

Re: Linus Torvalds on aliasing

#257

Earlier quoted context omitted.

Can the maintenance of the Linux kernel be considered a success?

Your implication, that this aspect of Torvalds' interpersonal style is vindicated by Linux' success, is a classic Halo effect. Post hoc ergo propter hoc.

I'm answering your question: maybe that's how he measures its success.

Re: Linus Torvalds on aliasing

#258

Earlier quoted context omitted.

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 th…

I probably didn't, but sometimes doing so helps you come to deeper conclusions and a better understanding of your own points.

My feeling is that people who need to be abusive of others are compensating some of their feelings about themselves. I think everybody does this though, I am no angel myself either. I just thought that people who are highly visible and in some way represent our industry, like Linus, should not be praised for being 'bad ass' when they are needlessly rude to people who are contributing. On a whole though, anyone can do what they want, and I can form an opinion based on what people do of course ;)

Yes, haha, Rocket League teammates sometimes don't excel at being good sports.

Re: Linus Torvalds on aliasing

#259
post #84

Earlier quoted context omitted.

It's actually like a rough drill sergeant. "Spoiled little princesses" are those that can't take some strong words and need hugs and smiles...

It's also people who throw fits with little provocation when they don't like things, which sounds fitting to me. Seriously, the thing gets merged anyway but he has to "express himself"

I found your post aggressive. Will you please change it to appease me?

Re: Linus Torvalds on aliasing

#260
post #238

Earlier quoted context omitted.

I think the clang and gcc contributors consider all this in combination with “strict aliasing” and “type” consistency attitude effectively if you just wrote a double to a union member, you can’t expect that reading integer from the same union has any meaning at all so they optimized that away “per standard”. To come to that, it’s not what is explicitly written when you do a keyword search for “union” but what is not…

> if you just wrote a double to a union member, you can’t expect that reading integer from the same union has any meaning at all so they optimized that away “per standard”. gcc 4.9.2 for sure does not (-O3 -fstrict-aliasing). Not sure what clang does, but I'd be surprised if it ignores the standard. The standard makes it pretty clear what meaning it will have. Sure, gcc and clang maintainers may seem to read the stan…

Googling I've found for example this:

GNU extensions to standard C++ (and to C90) do explicitly allow type-punning with unions. Other compilers that don't support GNU extensions may also support union type-punning, but it's not part of the base language standard.

Also, apparently in C99 one relevant statement was:

“The value of a union member other than the last one stored into [is unspecified]

https://stackoverflow.com/questions/25664848/unions-and-type...

Note: In case it's not obvious, I, personally, believe that, at least, using unions for type-punning has to exist and should be explicitly supported in the standards too. And that the compiler contributors should not produce practically unusable results even when some standard is wrong (for common use) or unclear. But the quotes like the above give a hint on which basis some try to cling to bad approaches in this special case. In other cases it's probably even harder to avoid unwanted results.

Post reply on HN