←back to thread

The C23 edition of Modern C

(gustedt.wordpress.com)
397 points bwidlar | 1 comments | | HN request time: 0s | source
Show context
ralphc ◴[] No.41851601[source]
How does "Modern" C compare safety-wise to Rust or Zig?
replies(4): >>41852048 #>>41852113 #>>41852498 #>>41856856 #
renox ◴[] No.41852048[source]
You'd be surprised: Zig has one UB (Undefined Behaviour) that C doesn't have!

In release fast mode, unsigned overflow/underflow is undefined in Zig whereas in C it wraps.

:-)

Of course C has many UBs that Zig doesn't have, so C is far less safe than Zig, especially since you can use ReleaseSafe in Zig..

replies(2): >>41852363 #>>41852615 #
uecker ◴[] No.41852363[source]
UB is does not automatically make things unsafe. You can have a compiler that implements safe defaults for most UB, and then it is not unsafe.
replies(4): >>41852548 #>>41853004 #>>41853083 #>>41853762 #
ahoka ◴[] No.41852548{3}[source]
By definition UB cannot be safe.
replies(2): >>41853174 #>>41854910 #
1. marssaxman ◴[] No.41853174{4}[source]
this depends on your choice of definition for "safe"