Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
flatfinger
searching Neon…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
6 ms
·
1.
▲
by
flatfinger
6y ago
In many cases, the semantics programmers would require are much looser than anything provided for by the Standard. For example, if a programmer requires an expression that computes (x \* y / z) when there is no overflow, and computes
2.
▲
by
flatfinger
6y ago
There are many cases where accommodating weird corner cases would be expensive, and would only be useful for some kinds of program. Requiring that all implementations intended for all kinds of task handle corner cases that won't be re
3.
▲
by
flatfinger
6y ago
> Yes, clearly. Unfortunately, the C Standard doesn't specify an abstraction model that is amenable to the optimization of usable programs. > In that case, I'm not sure what we're even arguing about; the language standa
4.
▲
by
flatfinger
6y ago
> With, I presume, a eye toward further producing: x.a[dat[i]] = i; y.a[dat[i]] = i; Bingo. > I assume you mean zero-extending; otherwise `x=255` would result in `result=-1`, which is clearly wrong. Naturally. > None of this in
5.
▲
by
flatfinger
6y ago
Replying to the code [discussed deeper in this sub-thread]: struct blob { uint16_t a[100]; } x,y,z; void test2(void) { int indices[] = {1,0}; { int* dat = indices; int n = 2; {
6.
▲
by
flatfinger
6y ago
The indent is getting rather crazy on this thread; I'll reply further up-thread so as to make the indent less crazy.
7.
▲
by
flatfinger
6y ago
Yeah, I meant `slow_function_no_side_effects(x)`. My point is that there's a huge difference between saying that a compiler need not treat a loop as sequenced with regard to outside code if none of the operations therein are likewise
8.
▲
by
flatfinger
6y ago
What should be relevant is not programmer "intent", but rather whether the behavior would likely match the that of an implementation which give that describe behavior of actions priority over parts of the Standard that would chara
9.
▲
by
flatfinger
6y ago
Has there ever been any consensus as to what that "...or is copied as an array of character type..." text is supposed to mean, or what sort of hoops must be jumped through for a strictly conforming program to generate an object wh
10.
▲
by
flatfinger
6y ago
The ability to use pointers to structures with a Common initial Sequence goes back at least to 1974--before unions were invented. When C89 was written, it would have been plausible that an implementation could uphold the Common Initial Seq
11.
▲
by
flatfinger
6y ago
How about allowing `return` to be used as a qualifier within a function or prototype's argument which, if present, would adjust the qualifiers of the function's return value to match those of the argument, e.g. adding "const&
12.
▲
by
flatfinger
6y ago
Functions like malloc are only required for hosted implementations. Many operating systems are built using freestanding implementations. Further, on many platforms, one should avoid using malloc() unless portability is more important than
13.
▲
by
flatfinger
6y ago
> This won't work because defective implementations will just claim that their intended purpose is to do [whatever emergent behaviour that implementation produces], or to generate the fastest code possible regardless of whether that
14.
▲
by
flatfinger
6y ago
> If I understand correctly, that would actually be "implementation-defined", not "undefined". That is an extremely common myth. From the point of view of the Standard, the difference between Implementation Defined b
15.
▲
by
flatfinger
6y ago
See post above. There is no good way for compilers to handle that case, but gcc gets "creative" even in cases where the authors of C89 made their intentions clear.
16.
▲
by
flatfinger
6y ago
I can't really blame gcc for that one, since the most straightforward way of using signed integer arithmetic would yield a negative value if the result is bigger than INT_MAX, but it would be very weird that programs would expect and r
17.
▲
by
flatfinger
6y ago
It's too bad Unicode wasn't designed around the concept of easily-recognizable grapheme clusters and "write-only" [non-round-trip] forms that are normalized in various ways. A text layout engine shouldn't have to h
18.
▲
by
flatfinger
6y ago
A conforming implementation could extend the language with an 8-bit type __nonaliasingbyte which has no special aliasing privileges, and define uint8_t as being synonymous with that type. On the other hand, the Standard should never have gi
19.
▲
by
flatfinger
6y ago
If the Standard were to make recursion an optional feature, many programs' stack usage could be statically verified. Indeed, there are some not-quite-conforming compilers which can statically verify stack usage--a feature which for ma
20.
▲
by
flatfinger
6y ago
If a compiler decides that it's going to process: unsigned mul(unsigned short x, unsigned short y) { return x*y; } in a way that causes calling code to behave in meaningless fashion if x would exceed INT_MAX/y [someth
21.
▲
by
flatfinger
6y ago
If one wants a function that will compute x y/z when x y doesn't overflow, and yield some arbitrary value (but without other side-effects) when it does, wrapping functions will often be much slower than would be code that doesn&#x
22.
▲
by
flatfinger
6y ago
72 static in-line functions. If a compiler does a good job of handling such things efficiently, most of them could be accommodated by chaining to another function once or twice (e.g. to read a 64-bit value that's known to be at least
23.
▲
by
flatfinger
6y ago
What is meant by "portable code"? Should it refer only to code that should theoretically be usable on all imaginable implementations, or should it be expanded to include code which may not be accepted by all implementations, but
24.
▲
by
flatfinger
6y ago
BTW, what do you think of the suggested text I offered near the top of this thread, that UB represents a waiver of the Standard's jurisdiction for the purpose of allowing implementations to best serve their intended purposes? It'
25.
▲
by
flatfinger
6y ago
> C's charter is to standardize existing practice (as opposed to invent new features), and no such feature has emerged in practice. Same for modules. (C++ takes a very different approach.) One thing that I'd really like to see
26.
▲
by
flatfinger
6y ago
I don't know if you saw my question right below, since I guess I replied to the wrong post, but I'd be really interested to know how you view the purpose of the Standard. For years, the language has been caught in a catch-22 wher
27.
▲
by
flatfinger
6y ago
Such an interpretation would be the only way to justify the way the maintainers of clang and gcc actually behave in response to complaints about their compilers' "optimizations".
28.
▲
by
flatfinger
6y ago
Rather than trying to come up with "compromise aliasing rules", the Standard needs to recognize that different tasks require different features, and allowing all possible optimization opportunities that would be useful for some ta
29.
▲
by
flatfinger
6y ago
What makes pointer provenance really great is that clang and gcc will treat that pointers that are observed to have the same address as freely interchangeable, even if their provenance is different. Clang sometimes even goes so far with th
30.
▲
by
flatfinger
6y ago
> When you handle unsanitized input in C on a security boundary, you must literally treat the compiler as a "lawful evil" accomplice to the attackers: you must assume that the compiler will follow the spec to the letter, but wi
More ›