[Bug c++/20180] New: Scope error using constructor argument with assignment-like syntax
bugzilla-t05k1 at email dot galacticnorth dot net
gcc-bugzilla@gcc.gnu.org
Thu Feb 24 01:56:00 GMT 2005
When declaring a variable which hides a same-named variable from a higher scope.
If the new variable is initialized from the same-named variable using the
assignment-like constructor syntax AND there was an earlier hiding of the same
variable name...
The value used for the initialization value comes from the earlier hidden (now
out of scope) version of the variable!
Simple example:
int main()
{
int i = 1;
{ int i = 22; }
{ int i = i; cout << i << '\n'; } // Prints 22!
{ cout << i << ' '; int i = i; cout << i << '\n'; } // Prints "1 22"!!
{ int i(i); cout << i << '\n'; } // Prints 1 (as expected)
}
--
Summary: Scope error using constructor argument with assignment-
like syntax
Product: gcc
Version: 3.3.5
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: bugzilla-t05k1 at email dot galacticnorth dot net
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i486-pc-linux-gnu
GCC host triplet: i486-pc-linux-gnu
GCC target triplet: i486-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20180
More information about the Gcc-bugs
mailing list