← Back to context

Comment by tialaramex

3 years ago

The compiler has an as-if rule on its side.

It's allowed to do whatever it wants so long as the results are as-if it did what the standard says. So even though the standard says this is making a big list of integers like your xxd command, the compiler won't do that, because (as a C compiler) it knows perfectly well it would just parse those integers into bytes again, just like the ones it got out of the binary file. It knows the integers would all be valid (it made them) and fit in a byte (duh) and so it can skip the entire back-and-forth.

If I understand correctly what you're saying it's not a problem with xxd itself, but with the format of the data, which in xxd's case is a pair made out of an array of bytes and its length, while the compiler is free to include the binary verbatim and just provide access to it as it was an array/length pair. Am I right about it?