[Bug c++/58063] default arguments evaluated twice per call

daniel.kruegler at googlemail dot com gcc-bugzilla@gcc.gnu.org
Sat Aug 3 21:23:00 GMT 2013


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58063

--- Comment #6 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
(In reply to Paolo Carlini from comment #5)
> Ah, in case isn't obvious already: it only happens when the "I/O expression"
> has the ! operator in front.

I suspected that and ensured that I added a similar operator! to my ostream
model type, but this hadn't any impact on the outcome for that type. Further, I
don't understand how it is related to ostream initialization, because the issue
also occurs when we invert the order of the function calls:

int main() {
 f2();
 std::cout << "------------------\n";
 f();
}

gives me:

<quote>
hi!
0
------------------
hi!
hi!
0
</quote>

Are you sure that this is not due to improper code generation?


More information about the Gcc-bugs mailing list