[Bug c++/36744] function modifying argument received by-value affects caller's variable when passed as rvalue

2009-01-31 Thread rguenth at gcc dot gnu dot org
--- Comment #5 from rguenth at gcc dot gnu dot org 2009-01-31 17:25 --- Confirmed. struct S { S(): i(2) {} S(S const&); int i; }; void f(S x) { x.i = 0; } extern "C" void abort (void); int main() { S y; f(static_cast(y)); if (y.i != 2) abort (); return 0; } declarin

[Bug c++/36744] function modifying argument received by-value affects caller's variable when passed as rvalue

2009-01-31 Thread michal at rzechonek dot net
--- Comment #4 from michal at rzechonek dot net 2009-01-31 16:58 --- I think that this bug is related to failure in code below: class movable { int resource; // 0=not acquired movable(const movable&); // no copy c'tor void operator=(const movable&); // no copy-assignment pub

[Bug c++/36744] function modifying argument received by-value affects caller's variable when passed as rvalue

2008-07-06 Thread chris dot fairles at gmail dot com
--- Comment #3 from chris dot fairles at gmail dot com 2008-07-06 19:51 --- (In reply to comment #2) > (In reply to comment #0) > > struct S > > { > > S(): i(2) {} > //S(S const&) {} > S(S const&); > The cctor need only be defined as well to get the same behavior (gcc 4.4.0, > -

[Bug c++/36744] function modifying argument received by-value affects caller's variable when passed as rvalue

2008-07-06 Thread chris dot fairles at gmail dot com
--- Comment #2 from chris dot fairles at gmail dot com 2008-07-06 19:33 --- (In reply to comment #0) > Consider: > > #include > > struct S > { > S(): i(2) {} //S(S const&) {} S(S const&); The cctor need only be defined as well to get the same behavior (gcc 4.4.0, -std=c++0x

[Bug c++/36744] function modifying argument received by-value affects caller's variable when passed as rvalue

2008-07-06 Thread gcc-bugzilla at contacts dot eelis dot net
--- Comment #1 from gcc-bugzilla at contacts dot eelis dot net 2008-07-06 14:48 --- Forgot to mention: compile with -std=c++0x. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36744