HN
Hacker News
Top
New
Best
Ask
Show
Jobs
Comment by hoseja | Hacker News Reader
Parent
Full thread
hoseja
·
weak typing: 2 + "2" is 22
View on HN
RUnconcerned
·
could also be "4" or 4! 4 seems like it would be the most evil option, honestly
pjc50
·
The real evil option is C: 2+"22" = 0, 4+"4" = undefined behavior and probably the value of some other variable.
manwe150
·
I think you meant: "22"+2 = "", and it is not UB to make the second pointer, only to use it
hoseja
·
The pointer arithmetic works both ways, same as square brackets.
sehansen
·
The real horror is "1d9" + 1 = 2, as does PHP:
https://3v4l.org/Dn6Sm
baq
·
or the most sane, depending on context... e.g. awk and perl do this.
Reply on news.ycombinator.com