top | item 46357638

(no title)

newpavlov | 2 months ago

LOL, nope. Those annotations must be part of the type system (e.g. `&mut T` in Rust) and must be checked by the compiler (the borrow checker). The language can provide escape hatches like `unsafe`, but they should be rarely used. Without it you get a fragile footgunny mess.

Just look at the utter failure of `restrict`. It was so rarely used in C that it took several years of constant nagging from Rust developers to iron out various bugs in compilers caused by it.

discuss

order

aw1621107|2 months ago

Does make me wonder what restrict-related bugs will be (have been?) uncovered in GCC, if any. Or whether the GCC devs saw what LLVM went through and decided to try to address any issues preemptively.

newpavlov|2 months ago

IIRC at least one of the `restrict` bugs found by Rust was reproduced on both LLVM and GCC.

gpderetta|2 months ago

gcc has had restrict for 25 years I think. I would hope most bugs have been squashed by now.