Live data from Hacker News

Tell HN: C Experts Panel – Ask us anything about C

news.ycombinator.com

301–310 of 978 posts

Re: Tell HN: C Experts Panel – Ask us anything about C

#301
post #296

Has Annex K been axed yet, and if not, why not?

It has not. The C Committee has taken two votes on this, and in each case, the committee has been equally divided. Without a consensus to change the standard, the status quo wins.

Sounds like you don't care for Annex K. What don't you like about it?

Re: Tell HN: C Experts Panel – Ask us anything about C

#302
Does the committee have plans to deprecate (as in: give compiler license to complain suchthat compiler developers can appeal to yhe standard when users complain back) locale-sensitive functions like isdigit, which is useless for processing protocol syntax, because it is locale-sensitive, and useless for processing natural-language text, because it examines only one UTF-8 codw unit?

Re: Tell HN: C Experts Panel – Ask us anything about C

#303
post #283

Earlier 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?

I'm guessing you were asking about this part rather than UB in general:

> Except for the special case of unsigned char,

The SO article makes the bizarre claim that because

(1) an unsigned char, per the standard, cannot have any padding bits, it therefore cannot have a trap representation. And

(2) if it cannot have a trap representation, the use of an uninitialized value isn't undefined.

I'm willing to buy (1) but I don't remember (2) being required for UB. I think (2) is the step that is harder to follow intuitively. Admittedly, I have not read that part of the standard closely in some time.

Re: Tell HN: C Experts Panel – Ask us anything about C

#304

is there no way to make C "memory-safe" during compilation?

There are a bunch of research projects that did just that. And even just compiling with address sanitizer makes it "memory-safe" to a significant degree.

can you link any to check out?

Re: Tell HN: C Experts Panel – Ask us anything about C

#305

Earlier quoted context omitted.

No, it's exactly the opposite. Without UB the compiler must assume that the corner case may arise at any time. Knowing it is UB we can assert `n+1 > n`, which without UB would be true for all `n` except INT_MAX. Standardising wrap-on-overflow would mean you can now handle that corner case safely, at the cost of missed optimisations on everything else.

I/we understand the optimization, and I'm sure you understand the problem it brings to common procedures such as DSP routines that multiply signed coefficients from e.g. video or audio bitstreams: for (int i = 0; i If inputA[i] * inputB[i] overflowed, why are my credit card details at risk? The question is: can we come up with an alternate behaviour that incorporates both advantages of the i<=N optimization, as well…

Another problem is that there's no way to define it, because in that example the "proper" way to overflow is with saturating arithmetic, and in other cases the "proper" overflow is to wrap. Even on CPUs/DSPs that support saturating integer arithmetic in hardware, you either need to use vendor intrinsics or control the status registers yourself.

Re: Tell HN: C Experts Panel – Ask us anything about C

#306
Is the committee planning on working on the preprocessor? I don't see any reason for not boosting it. It's time for C to have real meta-programming. Would be nice to have local macros that are scoped.

On another note:

- Official support for __attribute__

- void pointers should offset the same size as char pointers.

- typeof (can't stress this one enough)

- __VA_OPT__

- inline assembly

- range designated initializer for arrays

- some GCC/Clang builtins

- for-loop once (Same as for loop, but doesn't loop)

Finally, stop putting C++ craps into C.

Re: Tell HN: C Experts Panel – Ask us anything about C

#307

As there are a lot of C-masters lurking in this thread: How can one process unicode (UTF-8) properly in C? As a CJK person, I wish there was a robust solution. Are there any standardized ways or proposals? (Using wchar doesn't count.)

UTF-8 encoding works "as is" based on byte strings (char[]). The latest versions of the draft standard provide somewhat more support. I recommend heading toward a future where only UTF-8 encoding is used for multibyte characters and UCS-2 or similar for wchar_t. There is no need to support several different encodings.

[deleted]

Re: Tell HN: C Experts Panel – Ask us anything about C

#308

When deciding on standardized behavior for C operations or data representation that may favor some hardware over others [1], who argues the side of the various hardware vendors, if they have no members on the standardization committee? Is 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…

> When deciding on standardized behavior for C operations or data representation that may favor some hardware over others [1], who argues the side of the various hardware vendors, if they have no members on the standardization committee?

The C committee has a number of implementation vendors on it (GCC, Clang, IBM, Intel, sdcc, etc) and these folks do a good job of speaking up about the hardware they have to support (and in some cases, they're also the hardware vendor). If needed, we will also research hardware from vendors who have no active representation on the committee, but this is usually for more broad changes like "can we require 2's complement?".

> Is 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?

In my experience, the committee members typically do a good job of differentiating between "this is my opinion" and "this is my employer's opinion" during discussions where that matters. However, at the end of the day, each committee member is there representing some constituency (whether it's themselves or their company) and votes their own conscience.

Re: Tell HN: C Experts Panel – Ask us anything about C

#310
post #249

Earlier quoted context omitted.

How about a Sudoku solver? Send me a request via e-mail.

Doug, the email address in your account is private by default, but you can make it public by putting it in the About field of your profile at https://news.ycombinator.com/user?id=DougGwyn . ender1235, if you don't see an email address there, email hn@ycombinator.com and I'll put you in touch.

Okay, check my About text. I'll soon remove it, to avoid getting a lot of spam.
Post reply on HN