logoalt Hacker News

saagarjhatoday at 11:16 AM5 repliesview on HN

What should the behavior above be defined to do?


Replies

tsukikagetoday at 12:31 PM

“Implementation defined behaviour”: compiler author chooses, and documents the choice.

A lot of UB should be implementation defined behaviour instead; this would much better match programmers’ intuitions as they reason about their code - you can even see it in the comments of this post: it’s always things like “this hardware supports / doesn’t support unaligned accesses”, it’s never nasal demons.

show 1 reply
Filligreetoday at 12:00 PM

Print x twice. Not all “side effects” care about order.

Better yet, define an order for parameter evaluation.

show 1 reply
echoangletoday at 11:57 AM

Couldn’t you just define that function arguments are evaluated left to right?

Or just throw an error.

show 2 replies
lll-o-llltoday at 11:37 AM

HCF

show 2 replies
jefffffftoday at 11:40 AM

Compilation error

show 1 reply