This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/18468] New: bad code in template function called from template class method
- From: "james_avera at yahoo dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Nov 2004 20:30:56 -0000
- Subject: [Bug c++/18468] New: bad code in template function called from template class method
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
A template function (which swaps two values)
is called in a loop in an inlined method of a template class. The number
of loop iterations is a constant, so the compiler might be trying to unroll
the loop.
The final assignment of the swap function is not executed after the
first iteration, causing incorrect results.
The problem occurs with -O2 or -O3, but not with -O.
I will attach a self-contained demo program.
--
Summary: bad code in template function called from template class
method
Product: gcc
Version: 3.3.3
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: james_avera at yahoo dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i586-suse-linux-gnu
GCC host triplet: i586-suse-linux-gnu
GCC target triplet: i586-suse-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18468