Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
pascal_cuoq
searching Neon…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
6 ms
·
1.
▲
by
pascal_cuoq
5y ago
Yes, the first two examples in the article weren't obviously enough undefined for the authors of CIL who wrote the list, apparently.
2.
▲
by
pascal_cuoq
5y ago
This list contains several invalid items mixed with the good ones. It starts: Why does the following code return 0 for most values of x? (This should be easy.) int x; return x == (1 && x); The answer is that t
3.
▲
by
pascal_cuoq
5y ago
The sentence you quote is near to the words: “[The C++ standardization committee] WG21 has recently adapted the changes promoted in their document p12363. Generally, C++ goes much beyond what is presented here:” I would be extremely surpris
4.
▲
by
pascal_cuoq
6y ago
You need to look at the disassembly of the generated binary to make sense of this sort of performance variation (paying attention to line cache boundaries for code and data), and even so, it is highly non-trivial. The performance counters f
5.
▲
by
pascal_cuoq
6y ago
UBSan does detect and report misaligned pointer accesses in the latest versions of GCC and Clang: https://gcc.godbolt.org/z/xpSbXL
6.
▲
by
pascal_cuoq
6y ago
I have seen it said in another thread that UBSan detects this. If you aren't already using all the sanitizers that come with your {CLang, GCC} compiler, you should! They are great! UBSan detects everything that can be detected without
7.
▲
by
pascal_cuoq
6y ago
Please explain to me why you think it is. The clause says: “If the value being stored in an object is read from another object that overlaps in any way the storage of the first object, then the overlap shall be exact and the two objects sha
8.
▲
by
pascal_cuoq
6y ago
So the clause about assignment? Thanks, that was helpful.
9.
▲
by
pascal_cuoq
6y ago
1 is not an object, but even if it was one, it would not be an object that overlaps with “* p”. You are interpreting the C standard as if it were a philosophy text. It contains a rule that says that in very precise circumstances (for an ass
10.
▲
by
pascal_cuoq
6y ago
This line of J.2 only refers to the already cited 6.5.16.1. You keep quoting this clause as if it applied to any of the assignments in the program being discussed. It doesn't. That clause says that in an assignment of the form “lvalue1
11.
▲
by
pascal_cuoq
6y ago
6.5.16.1 is the “rule that only apply to “lvalue = lvalue;” assignments and is not relevant here” It does not apply to “lvalue = 1;” or to “lvalue = 2;”, which are the two relevant assignments in the example in the article. For context, I t
12.
▲
by
pascal_cuoq
6y ago
Could you clarify which clause of the C standard you are referring to when you say “due to aliasing, not due to alignment”? I make sense of the C standard for a living (this is literally my day job) and I do not see what clause of the C sta
13.
▲
by
pascal_cuoq
6y ago
I have heard this reaction to this article a lot, but sorry, there is nothing in the C standard that says that objects should not overlap, except a rule that only apply to “lvalue = lvalue;” assignments and is not relevant here. Plus on a s
14.
▲
by
pascal_cuoq
6y ago
Author here! I am not saying or thinking that there is a problem with GCC. I do think that GCC and Clang would be more useful with an option to make them not assume that every pointer is aligned if the target architecture does not impose th
15.
▲
by
pascal_cuoq
6y ago
That may be the case in C++, but in C infinite loops are allowed as long as the controlling condition is a constant expression (making it clear that the developper intends an infinite loop). These infinite loops without side-effects are eve
16.
▲
by
pascal_cuoq
6y ago
The problem in practice is that you do not write “hello” and “world” to the destination buffer. You write data that is computed more or less directly from user inputs. Often a malicious user. So the user only needs to find a way to make the
17.
▲
by
pascal_cuoq
6y ago
Oh, that was your question. In this case, the reason why &a + 1 == &b is unspecified is that: - it's generally false—there is no reason for b to be just after a in memory, so these two addresses compare different. - it is somet
18.
▲
by
pascal_cuoq
6y ago
If you wrote down your proposal, which the C committee member Robert Seacord is encouraging you to do here: https://news.ycombinator.com/item?id=22870210 , you would have to think carefully about functions that are pure acc
19.
▲
by
pascal_cuoq
6y ago
Thanks Dan, I missed this question in the heat of the moment.
20.
▲
by
pascal_cuoq
6y ago
I still want to write at least one sequel to that post, on the theme “Alright, can we make a Friendly C Compiler by disabling the annoying optimizations, then?”. Obviously the people who want a Friendly C Compiler do not want to disable al
21.
▲
by
pascal_cuoq
6y ago
3. would have to be a new mechanism for variadic functions, that would have to be distinguished in header files from the old mechanism with which it is incompatible. So this proposal would imply some new keyword or syntax. I am not in the c
22.
▲
by
pascal_cuoq
6y ago
For what it's worth, I personally like this approach, because there are some cases in which it requires less arithmetic in order to be used correctly. And it lends itself better to some forms of static analysis, for similar reasons, in
23.
▲
by
pascal_cuoq
6y ago
Unfortunately I am out of useful information: https://news.ycombinator.com/item?id=22868999 I hope someone will provide the next link.
24.
▲
by
pascal_cuoq
6y ago
If I remember correctly, Chandler was the one writing down the draft for LLVM developers to comment on LLVM-side. Unfortunately, if you Google his name and the relevant keywords, the results are full of his work on speculative load hardenin
25.
▲
by
pascal_cuoq
6y ago
One concrete reason why “unspecified” means “anything and not always the same thing” is to enable the maximum of optimizations. Write a function c that compares pointers in a compilation unit, and in another compilation using, define:
26.
▲
by
pascal_cuoq
6y ago
Here is an example I have at hand that shows that when you are using an optimizing compiler, there is no such thing as “just pointers to addresses in memory”. There are plenty more examples, but I do not have the other ones at hand. https:
27.
▲
by
pascal_cuoq
6y ago
I think this is plenty ok. For one thing, If a struct as a member of type T, it's ok to access it through a pointer to T (and also the address of the struct is guaranteed to be identical to the address of the first member). For another
28.
▲
by
pascal_cuoq
6y ago
The only thing that is not defined is comparing a pointer one-past-the-end to a pointer to the very beginning of a toplevel object. Apart from this rule, pointers of course do not need to be derived from the same object in order to be compa
29.
▲
by
pascal_cuoq
6y ago
The C standard also allows to use memcpy to do type punning: If a value is copied into an object having no declared type using memcpy or memmove, or is copied as an array of character type, then the effective type of the modified
30.
▲
by
pascal_cuoq
6y ago
This example is clearly UB. You could argue that it suddenly becomes less UB if you take the address of x: unsigned int x; &x; x -= x; I'm not sure if this will add anything to the discussion on SO, but if you allow prog
More ›