News for hackers. Stuff that matters.
Re:Checked-size array parameters in C by MobiusHorizons on Wednesday December 03, 2025 @11:37PM (#46143857)
Wow, that’s crazy. Does anyone have any context on why they didn’t fix this by either disallowing NULL, or not treating the pointer as non-nullable? I’m assuming there is code that was expecting this not to error, but the combination really seems like a bug not just a sharp edge.
Re:Checked-size array parameters in C by jacquesm on Thursday December 04, 2025 @05:49AM (#46146116)
Indeed, at a minimum you should be able to enforce that check using a compiler flag.
Re:Checked-size array parameters in C by uecker on Thursday December 04, 2025 @06:28PM (#46154733)
You can add that check using -fsanitize=null (and you may want to turn the diagnostic into a run-time trap)
Re:Checked-size array parameters in C by int_19h on Friday December 05, 2025 @11:05PM (#46170586)
Treating the pointer as not-nullable is precisely the point of the feature, though. By letting the compiler know that there's at least N elements there, it can do things like e.g. move that read around and even prefetch if that makes the most sense.