Obvious Things C Should Do

Walter Bright newshound2 at digitalmars.com
Mon Jan 13 17:53:36 UTC 2025


On 1/13/2025 8:13 AM, Dukc wrote:
> On Monday, 13 January 2025 at 08:16:48 UTC, Walter Bright wrote:
>> D's CTFE does not allow undefined behavior.
> 
> It's pretty simple in D since it has the @safe subset where everything is 
> defined behaviour anyway.

It's a bit more than that. It doesn't allow shift counts larger than the size of 
the field being shifted. It's too expensive to add such a check to runtime code.


> But we're talking about C and there it'd be different. For example, using 
> uninitialised values and signed int overflows. In the specific case of DMD those 
> are probably still simple since it can just do what D does in the same 
> situation. But if you were writing (a formal proposal to change) the C standard, 
> how would you address those? I suspect it'd be complicated.

It wouldn't be hard for the engine to mark uninitialized variables.


More information about the Digitalmars-d mailing list