Earlier quoted context omitted.
I tried, but two spaces yielded what you saw.
Huh, it also needed an extra line break before the first line of code. I didn't realize that! I've fixed it now.
Tell HN: C Experts Panel – Ask us anything about C
291–300 of 978 posts
Re: Tell HN: C Experts Panel – Ask us anything about C
#292Is it fair to assume that hardware-related decisions occur in an environment where members who are sponsored by vendors argue their employers case, rather an a neutral one?
---
[1] E.g., because some hardware's behavior may more naturally implement the operation.
Re: Tell HN: C Experts Panel – Ask us anything about C
#293What is the story behind the removal of VLAs from C99 in later revisions?
Is a controverial feature, that can produce bugs, and are banned in a lot of project (one famouse, the Linux kernel).
Re: Tell HN: C Experts Panel – Ask us anything about C
#294Does the following code fragment cause undefined behaviour? unsigned int x; x -= x; There's a lengthy StackOverflow thread where various C language-lawyers disagree on what the spec has to say about trap values, and under what circumstances reading an uninitialised variable causes UB. I'd appreciate an authoritative answer. Thanks for dropping by on HN! https://stackoverflow.com/q/11962457/
Yes, it's undefined. It involves a read of an uninitialized local variable. Except for the special case of unsigned char, any uninitialized read is undefined.
Could you expand on this?
Re: Tell HN: C Experts Panel – Ask us anything about C
#295Earlier quoted context omitted.
I've been doing the same! It certainly helps for strings. Pointer block diagrams (like K&R use) seem to help too. Mostly what melts their brains is the idea that an identifier can be "in two places at once" - for example, you can have a variable x declared in some scope and a function one of whose arguments is named x, and those are two different things.
Try explaining the concept of "scope", starting with nested blocks. It does require some practice. I suggest not unnecessarily reusing identifiers associated with different objects.
Re: Tell HN: C Experts Panel – Ask us anything about C
#296Re: Tell HN: C Experts Panel – Ask us anything about C
#297Earlier quoted context omitted.
Yes, it's undefined. It involves a read of an uninitialized local variable. Except for the special case of unsigned char, any uninitialized read is undefined.
>Except for the special case of unsigned char, any uninitialized read is undefined. Could you expand on this?
Re: Tell HN: C Experts Panel – Ask us anything about C
#298Earlier quoted context omitted.
In the same vein, I really like being able to use underscores in binary and hex literals to denote subfields in hardware registers. 0xDEADB_EEF 0b1_010_110111001001 etc.
Should take Verilog binary construction syntax, like { 12'd12, 16'hffee, 3'b101 } (or something similar that would fit with C's syntax).
Re: Tell HN: C Experts Panel – Ask us anything about C
#299Earlier quoted context omitted.
I am sorry I do not have an answer to your question. It's a very valid one and I would be interested in any pointer to an answer. What I can say while we are on the subject, is that I have seen C code (most often C code that started its life in the 1990s, to be fair) that instead of showing an abstract struct in the public interface, showed a different struct definition. Please don't do this. Yes, when compiling nowa…
Wait, doesn't this mean that the BSD sockets API is inherently dependent on UB, casing different socket types to each other and sometimes only using the first few members, or am I misunderstanding you?
Re: Tell HN: C Experts Panel – Ask us anything about C
#300Now that C2x plans to make two's complement the only sign representation, is there any reason why signed overflow has to continue being undefined behavior? On a slightly more personal note: What are some undefined behaviors that you would like to turn into defined behavior, but can't change for whatever reasons that be?
Signed overflow being undefined behavior allows optimizations that wouldn't otherwise be possible Quoting http://blog.llvm.org/2011/05/what-every-c-programmer-should-... > This behavior enables certain classes of optimizations that are important for some code. For example, knowing that INT_MAX+1 is undefined allows optimizing "X+1 > X" to "true". Knowing the multiplication "cannot" overflow (because doing so would be…