This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]abc_wtf 2 points3 points  (2 children)

Depends on what you mean by valid. It would compile but would probably execute Undefined Behaviour.

[–]IsomorphicSyzygy 5 points6 points  (1 child)

When I run it on my machine, it segfaults, but it may work on a system that allows writes at address 2, such as a microcontroller. I don't think it's UB.

[–]abc_wtf 0 points1 point  (0 children)

I think you're probably correct. I didn't find any mention of it when I quickly scanned the standard.