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…
You'd be surprised to see how many comments are removed from HN by the mods each day. What you see here is not what HN users actually are.
Linus Torvalds on aliasing
231–240 of 284 posts
Re: Linus Torvalds on aliasing
#232Earlier quoted context omitted.
I can't stand when you're expected to wrap every sentence in some sugar coated fake 'niceness' just to not step on somebody's toes. If I have a certain way of expressing myself... Well that's how it is.
>> If I have a certain way of expressing myself... Well that's how it is. You shouldn't sell yourself short. Changing the way you communicate is a huge but worthwhile challenge. In a different time, I would have been mean to you over your comment instead of offering supportive words. It took as much effort to be nice as it used to take to be mean.
Re: Linus Torvalds on aliasing
#233Earlier 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.
Sure, swearing may indicate lack of self-control, but the lack of swearing does not indicate self-control, nor does the presence of swearing indicate lack of self-control. I once saw a doc about the alarming levels of rape in the U.S. military. Some of these guys were pretty high rank, so I guess they fooled everyone that they possessed self-control, (perhaps they didn't swear), but in reality they clearly lacked sel…
Re: Linus Torvalds on aliasing
#234Earlier quoted context omitted.
They are optional, but only in the sense that if you can't exactly represent e.g. uint64_t, there can't be a uint64_t type. So the example above is kosher in the sense that it's standards compliant, even if it isn't perfectly portable (for reasons unrelated to memset type punning; that you're using uint64_t in the first place). If an implementation can't represent uint64_t exactly, it can still have a uint_least64_t…
I certainly agree with what you said as you said it. However, as usual, it is the implementation that kills it. a) I believe sizeof (double) * 8 == 64 is not enforced by the standard either. One could argue that it is hard to find anything else these days, but (for a contrived example) I believe nothing prevents you from making your own port of GCC for some purpose, and make 'double' be 'float'. (From my memories, it…
sizeof (double) can be guaranteed to be 8 if __STDC_IEC_559__ is defined, so checking that is an additional hurdle if you want to use memcpy for punning. That said, I think it can be assumed that you're writing non-portable code for a specific set of platforms already if you are punning floats to integers, because the representation is implementation dependent in the first place. Probably you also know the environments in which it will be compiled as well, so the example is a bit contrived.
Very much agree that unions are the easiest and standard way to do type punning. There's so many misconceptions about this somehow being unclear in the standard. Sure, it does reflect poorly on the quality of the standard that Linux contributors don't understand it and that Linus Torvalds actively ignores it, but if you know what you're looking for it's often not that hard to find a definite answer.
Re: Linus Torvalds on aliasing
#235I 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…
My wife works in mental health, dealing with people at the very lowest ebb. You'd think the therapists' internal meetings would be full of carefully worded and graded polite discussion, but just yesterday she told me about a meeting where the lead therapist said to one particular member of the group, 'If you don't do X right, we're fucked. You are fucking us up!' I don't know if that's good or not, but it's not just…
I don't care for the tone, and all the dark patterns could be there too in the meeting, but your single quote on its own is not evidence of dysfunction.
Re: Linus Torvalds on aliasing
#236Earlier quoted context omitted.
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.
One circumstance where insults might be justified is where one party has ignored valid objections to his position. I mention this here because kristianic made the valid point that you have set up a false dichotomy, and you replied with a statement that keeps it going. Is the habit of not paying attention to the actual issues also part of your superior Northern European culture, and, in fact, is it perhaps a reason wh…
Re: Linus Torvalds on aliasing
#237Earlier quoted context omitted.
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.
One circumstance where insults might be justified is where one party has ignored valid objections to his position. I mention this here because kristianic made the valid point that you have set up a false dichotomy, and you replied with a statement that keeps it going. Is the habit of not paying attention to the actual issues also part of your superior Northern European culture, and, in fact, is it perhaps a reason wh…
Re: Linus Torvalds on aliasing
#238Earlier quoted context omitted.
AFAIK even using union for the above purpose can be seen as "undefined behavior" when reading standard, and that's why the standard is especially wrong, as it makes some typical desired (and needed) outcomes impossible to implement, and at the moment clang still has problems even with the union variant whereas gcc allows you to use union by passing the compiler switch which effectively has the semantics "we promise w…
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…
Re: Linus Torvalds on aliasing
#239Earlier 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…
You'd be surprised to see how many comments are removed from HN by the mods each day. What you see here is not what HN users actually are.
Re: Linus Torvalds on aliasing
#240Earlier 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…
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 know about it.