public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/52427] New: problem with default copy constructor and -O
@ 2012-02-29 7:22 architectbum at hotmail dot com
2012-02-29 14:50 ` [Bug c++/52427] [C++11] problem with defaulted " redi at gcc dot gnu.org
2013-05-25 10:58 ` paolo.carlini at oracle dot com
0 siblings, 2 replies; 3+ messages in thread
From: architectbum at hotmail dot com @ 2012-02-29 7:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52427
Bug #: 52427
Summary: problem with default copy constructor and -O
Classification: Unclassified
Product: gcc
Version: 4.6.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: architectbum@hotmail.com
Created attachment 26777
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26777
program with unexpected output
The attached program prints
> 181
> 181
as expected when compiled with "g++-4.6.2 --std=c++0x -o bin/main src/main.cc"
(or g++-4.5.3)
but
> 121
> 181
with any -O option, and even
> 17
> 181
with 4.5.3 with -O.
Replacing the default copy constructor of foo_iterator with a user-defined
constructor that should do the same thing (as in comment in source) fixes the
problem, as does compiling with -fno-elide-constructors. Also, as the testcase
shows, the problem arises with
> sum += *fi++;
but not with
> sum += *fi;
> ++fi;
even though the postfix increment is defined in the usual way; therefore, the
problem seems to lie in the temporary produced by operator++(int).
A GDB session suggested that the optimized-away default copy constructor may be
setting k to 0; that is, k=0 when operator*() is called on the temporary at
'*fi++'; this is consistent with the output. (And moving the "dereference"
inside operator++(int) so that it returns ulong does the same thing.)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/52427] [C++11] problem with defaulted copy constructor and -O
2012-02-29 7:22 [Bug c++/52427] New: problem with default copy constructor and -O architectbum at hotmail dot com
@ 2012-02-29 14:50 ` redi at gcc dot gnu.org
2013-05-25 10:58 ` paolo.carlini at oracle dot com
1 sibling, 0 replies; 3+ messages in thread
From: redi at gcc dot gnu.org @ 2012-02-29 14:50 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52427
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |wrong-code
Status|UNCONFIRMED |NEW
Last reconfirmed| |2012-02-29
Summary|problem with defaulted copy |[C++11] problem with
|constructor and -O |defaulted copy constructor
| |and -O
Ever Confirmed|0 |1
Known to fail| |4.5.2, 4.6.2, 4.7.0
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-02-29 14:38:47 UTC ---
It gets the wrong value on the 17th iteration, when check_advance() is called,
so you can make it fail sooner by change s/16/3/ in hex_iterator::operator++
and the initializer for pre_foo
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/52427] [C++11] problem with defaulted copy constructor and -O
2012-02-29 7:22 [Bug c++/52427] New: problem with default copy constructor and -O architectbum at hotmail dot com
2012-02-29 14:50 ` [Bug c++/52427] [C++11] problem with defaulted " redi at gcc dot gnu.org
@ 2013-05-25 10:58 ` paolo.carlini at oracle dot com
1 sibling, 0 replies; 3+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-05-25 10:58 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52427
Paolo Carlini <paolo.carlini at oracle dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Known to work| |4.7.2, 4.8.0, 4.9.0
Resolution|--- |FIXED
Target Milestone|--- |4.7.2
--- Comment #2 from Paolo Carlini <paolo.carlini at oracle dot com> ---
This is fixed. If you can still see something wrong please re-open, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-05-25 10:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-29 7:22 [Bug c++/52427] New: problem with default copy constructor and -O architectbum at hotmail dot com
2012-02-29 14:50 ` [Bug c++/52427] [C++11] problem with defaulted " redi at gcc dot gnu.org
2013-05-25 10:58 ` paolo.carlini at oracle dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).