VCTLabs/devmem2

Access to memory mapped registers is Undefined Behavior according to the C standard.

Closed this issue · 1 comments

ZiCog commented

Given that this code makes no use of "volatile" when reading and writing from mapped memory it's behavior is undefined as per the C standard.

As such it is only a matter of luck that it works at all!

I do not follow ZiCog's logic at all. The C standard makes no mention of mmap, or memory mapped registers, and the POSIX standard which defines mmap does not talk about volatile in this context.

Behavior is undefined when the standard states so, or when the code violates a "shall" constraint in the standard. I do not see that here.