News for hackers. Stuff that matters.
Re: by veltas on Tuesday September 09, 2025 @03:16AM (#45178584)
You can do f(int n, int (*a)[n]) and it does what it looks like, since C99.

https://godbolt.org/z/8dfKMrGqv

Re: by sirwhinesalot on Tuesday September 09, 2025 @03:43AM (#45178772)
That's an entirely different thing (VLAs)
Re: by veltas on Tuesday September 09, 2025 @03:44AM (#45178783)
There's no VLA in my example.
Re: by sirwhinesalot on Tuesday September 09, 2025 @04:14AM (#45179033)
Your example doesn't do any bounds checks, it just lets you get the sizeof. And the reason the sizeof works is the VLA infrastructure (which is not supported by MSVC so it won't compile the code).

What I want is -fbounds-safety from clang.

Re: by navi-desu on Tuesday September 09, 2025 @01:15PM (#45185143)
it does do bounds checks if you -fsanitize=bounds, in gcc at least

(and msvc is stuck on partial c11 support to this day, so imo, i don't quite think it's a fair target when comparing things to new features anyway)