Obvious Things C Should Do

Dukc ajieskola at gmail.com
Sun Jan 12 18:15:17 UTC 2025


On Saturday, 11 January 2025 at 23:31:14 UTC, Walter Bright wrote:
> https://news.ycombinator.com/item?id=42669637

I am suspicious that mandating CTFE in C standard would be a good 
idea. C is full of all sorts of undefined behaviour even in pure 
functions, and it'd be a security disaster if executing undefined 
behaviour at compile time would also be undefined behaviour. Also 
consider cross-compiling: the function might be different in the 
host and the target platform. This means it'd be quite complex to 
specify and implement.

Don't get me wrong, I think CTFE is a great idea. But C is 
intentionally only adding relatively small evolutionary changes. 
CTFE wouldn't fit that very well, especially since it'd be 
relatively limited in C thanks to lack of the garbage collector.

As for lack of forward declarations, maybe they want to avoid two 
different C standards compiling with different semantics.

```C
float foo(){ return 10.0 + bar(); }
float bar(void);
```

I believe this would compile in C90, but with `bar()` in `foo()` 
"returning" an `int` and therefore probably corrupting the stack.


More information about the Digitalmars-d mailing list