Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: I crashed 99 bottles.. the dot was the point (multiconcat)

by Laurent_R (Canon)
on Apr 26, 2019 at 10:17 UTC ( #1233009=note: print w/replies, xml ) Need Help??


in reply to I crashed 99 bottles.. the dot was the point (multiconcat)

It looks like an old and well-known (albeit somewhat obscure and tricky) problem in C (and C++): sometimes, you have to introduce sequence point (see for example https://en.wikipedia.org/wiki/Sequence_point and http://www.c-faq.com/expr/seqpoints.html for more details) to make sure that all side-effects from previous evaluations are completed and that no-side effect from subsequent evaluations has been performed. If you don't do that, the behavior is undefined, which means that different C compilers may yield different results and still comply with the C standard; and I have actually observed such discrepancy of behaviors many years ago (some time in the last decade of last century) between two C compilers.

One of the typical ways to introduce a sequence point in such an expression is to add a comma. This is presumably the reason why your version with commas works as expected.

Update: fixed a couple of typos.

  • Comment on Re: I crashed 99 bottles.. the dot was the point (multiconcat)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1233009]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (3)
As of 2020-09-22 03:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If at first I donít succeed, I Ö










    Results (128 votes). Check out past polls.

    Notices?