Hacker News new | ask | show | jobs
by ComputerGuru 1193 days ago
> a good conjecture is that n is the length of arr

As an old osdev currently enjoying using rust instead, I would say I wish.

N might be the length of arr. it might also correspond to the number of elements of (implicit) type t that would fit in the unsigned char array arr. It might be the length of the array minus space for a trailing char (either minus one or minus sizeof(char) bytes). Or it could be the size plus one, because why not.

2 comments

What you just described is the absolute bane of my existence at work in embedded firmware development. Though typically size_t does mean what it says on the tin — the horrific drivers usually use some other unsigned int type if they’re doing dumb stuff with “n” there.
Which is why it's only a conjecture. You need static analysis, SAT solving, and run-time checks to validate that conjecture.

Using something like GPT-4 on this problem is promising. It's probably going to be right most of the time, and its errors can be caught by the next phase of the analysis. That's about what you'd get if you put junior programmers on language conversion.