[Bug c++/58063] default arguments evaluated twice per call
fanael4 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Sun Aug 4 12:11:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58063
Fanael <fanael4 at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fanael4 at gmail dot com
--- Comment #10 from Fanael <fanael4 at gmail dot com> ---
My attempt at reducing:
struct basic_ios
{
virtual ~basic_ios() {}
bool operator!() const { return false; }
};
struct ostream : virtual basic_ios
{
ostream() {}
~ostream() {}
private:
ostream(const ostream&);
ostream& operator=(const ostream&);
};
ostream& operator<<(ostream& os, const char* s) {
__builtin_printf("%s", s);
return os;
}
ostream cout;
void f(bool x = !(cout << "hi!\n")) {
__builtin_printf("%d\n", static_cast<int>(x));
}
int main() {
f();
}
Seems like virtual inheritance is the culprit.
More information about the Gcc-bugs
mailing list