Live data from Hacker News

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

news.ycombinator.com

341–350 of 978 posts

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

#341
Open up WG14 mailing list for non-members?

It's hard to appreciate what's going on at WG14 (or take part) when you can see the results only from afar, with none of the surrounding discussion.

I recently read Jens Gustedt's blog on C2x where he casually recommended this as a way to get involved: "The best is to get involved in the standard’s process by adhering to your national standards body, come to the WG14 meetings and/or subscribing to the committee’s mailing list."

Afaict (from browsing the wg14 site), the mailing list and its archives are not open to access.

https://webcache.googleusercontent.com/search?q=cache:TnEGL4...

EDIT: In general, how is one supposed to approach wg14 with ideas or need for clarification on the standard's wording / interpretation?

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

#342
post #262

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.

I didn't realize that either, but it's described in formatdoc as such. So if you changed that behavior, probably should change the docs too.

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

#343

When deciding on the behavior of some operation that maps to hardware [1], how do you weight the existing hardware behaviors? For example, if all past, current and contemplated hardware behaves in the same way, I assume that the standard will simply enshrine this behavior. However, what if 99% of hardware behaves one way and 1% another? Do you set the behavior to "undefined" to accommodate the 1%? At what point to yo…

I would say that the committee does pay attention to hardware variations, even when there are no examples of existing hardware that implement a feature (for example, a trap representation for integers other than _Bool). Some of the thinking is that "if it was ever implemented in hardware, it could be again). I'm not crazy about this thinking, and I largely think that language features for which there are no existing hardware implementations should be eliminated and then brought back if needed. However, the C Committee is much smaller than the C++ committee so there is a labor shortage. More people getting involved would certainly help.

We have dropped support for sign and magnitude and one's complement architectures from C2x (a decision Doug Gwyn does not agree with). There was some concern that Unisys may still use a one's complement architecture, but that this may only be in emulation nowadays.

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

#344

Earlier quoted context omitted.

There are no aliasing differences between uint8_t and char as far as I know.

In practice not. In theory, it’s implementation-defined whether yhere are differences.

At least from what I've heard that's because stdint values are optional.

6.2.5p17 The three types char, signed char, and unsigned char are collectively called the character types. The implementation shall define char to have the same range, representation, and behavior as either signed char or unsigned char. 48)

and

5.2.4.2.1 says that width of char, signed char and unsigned char are the same (8).

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

#345
post #314

In C89 is there a portable way to figure out the alignment requirement for a struct, to be able to, say, store it after the NUL terminator in the same allocation as a C string?

I'm not sure what your requirement is. Usually things work out if you're careful not to assume any specific value for alignment etc. It may mean a few unused bytes here and there, but keeping things simple and portable often pays off.

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

#347

Does the committee have any plans to document the rationale for each kind of Undefined Behavior? Does the committee have any plans to make NULL pointer arguments to memcpy non-UB when the size argument is 0?

> Does the committee have any plans to document the rationale for each kind of Undefined Behavior?

In the C99 timeframe, we had a rationale document that was separately maintained. My understanding (this predates my joining the committee) is that this was prohibitively labor-intensive and so we stopped doing it for C11. I don't know of any plans to start doing this again, even in a limited sense for justifying UB. That said, we do spend time considering whether an aspect of a proposal requires UB or not, so the rationale exists in the proposals and committee minutes.

> Does the committee have any plans to make NULL pointer arguments to memcpy non-UB when the size argument is 0?

I have not seen such a proposal, and suspect that implementations may be concerned about losing their optimization opportunities from such a change. (Personally, I'd be okay losing those optimization opportunities as this does not seem like a situation where UB is necessary.)

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

#348
post #126

I'm teaching C to high schoolers as their first language, which is quite the adventure. Do you have any good advice or resources on how to introduce the way C treats the function stack and heap allocated memory? Most of my students struggle (naturally) with making sense of function scoped identifiers and pass-by-value semantics.

This service has been designed to try out small self-contained C examples online (in a manner reminiscent of Compiler Explorer):

https://taas.trust-in-soft.com/tsnippet/

One advantage is that it identifies a LOT of undefined behaviors during execution for which traditional compilation and execution only give puzzling results.

One drawback is that some of the undefined behaviors it identifies are obscure, and for others the message may be unusual. For instance, using a standard function without including the appropriate header may result in a warning about the mismatch between the type in the header and the type of the arguments the standard function was applied to after arguments promotions.

Overall, you may still find it useful for teaching.

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

#349

I know this opinion is unpopular and contradict with a core value of the C standardization committee but I personally think at some point, C standard should abandon supporting the legacy codebase. I think bool and stdint definitions should be available as part of the standard feature set and shouldn't need including their respective headers. These and some other features are available at the core of every modern lang…

Can't upvote enough. I think these changes could also be made in a way that can be mechanically-translatable.

For example: removing the register keyword, always requiring a return statement, etc etc.

A lot of changes can me made that will make static analysis easier.

There will always be people with 50 year old code bases that will never change (and some c89 compiler will always be there for them), but the language is pervasive enough that it deserves progressive changes to make it (even) simpler and safer and slightly more high level.

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

#350
Thoughts on Gnome glib, gobject, vala etc?

I tend to use glib for my (academic) code for pretending C is a high-level language. It also seems to make up for implementation-dependent functions in C and many portability issues. Also, IMO, vala > C++.

My question is, really, are there any other tools for high-level C programming and do you know of any disadvantages of the Gnome stack?

Post reply on HN