• Create Account

### #Actualkuramayoko10

Posted 10 October 2012 - 07:05 PM

I've faced this problem before.

I believe that this kind of thing with i/o streams
std::cout << a(&val) << val;

generates an Unspecified Behavior.

The std::cout function will print the arguments in the order you provided, but it cannot guarantee that they will be executed from lef-to-right or right-to-left.
I think that the compiler is the one that is translating this to a random order of execution. DevC++ (gcc?) did it left-to-right as you expected but the vc++ from Visual Studio did it differently.

Anyhow, I think it is better to break this line into two as you have shown above.

### #3kuramayoko10

Posted 10 October 2012 - 07:05 PM

I've faced this problem before.

I believe that this kind of thing with i/o streams
std::cout << a(&val) << val;

generates an Unspecified Behavior.
The std::cout function will print the arguments in the order you provided, but it cannot guarantee that they will be executed from lef-to-right or right-to-left.
I think that the compiler is the one that is translating this to a random order of execution. DevC++ (gcc?) did it left-to-right as you expected but the vc++ from Visual Studio did it differently.

Anyhow, I think it is better to break this line into two as you have shown above.

### #2kuramayoko10

Posted 10 October 2012 - 07:04 PM

I've faced this problem before.

I believe that this kind of thing with i/o streams
[source lang="c++"]std::cout << a(&val) << val; [/source]
generates an Unspecified Behavior.
The std::cout function will print the arguments in the order you provided, but it cannot guarantee that they will be executed from lef-to-right or right-to-left.
I think that the compiler is the one that is translating this to a random order of execution. DevC++ (gcc?) did it left-to-right as you expected but the vc++ from Visual Studio did it differently.

Anyhow, I think it is better to break this line into two as you have shown above.

### #1kuramayoko10

Posted 10 October 2012 - 07:04 PM

I've faced this problem before.

I believe that this kind of thing with i/o streams
[source lang="java"]std::cout << a(&val) << val; [/source]
generates an Unspecified Behavior.
The std::cout function will print the arguments in the order you provided, but it cannot guarantee that they will be executed from lef-to-right or right-to-left.
I think that the compiler is the one that is translating this to a random order of execution. DevC++ (gcc?) did it left-to-right as you expected but the vc++ from Visual Studio did it differently.

Anyhow, I think it is better to break this line into two as you have shown above.

PARTNERS