This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/48483] Construct from yourself w/o warning
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 7 Apr 2011 09:42:11 +0000
- Subject: [Bug c++/48483] Construct from yourself w/o warning
- Auto-submitted: auto-generated
- References: <bug-48483-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |diagnostic
--- Comment #9 from Jonathan Wakely <redi at gcc dot gnu.org> 2011-04-07 09:41:55 UTC ---
(In reply to comment #7)
> The example
>
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483#c2
>
> shows a compiler bug.
No it doesn't.
> TYPE VARIABLE [ARGUMENT-TO-CONSTRUCT]
>
> The compiler must doing like this:
> 1. Compile ARGUMENT-TO-CONSTRUCT
> 2. Checking of TYPE
> 3. VARIABLE declaration
No, the variable is in scope after its identifier, so it can be used in the
initializer expression, e.g.
int i = sizeof(i); // ok
int i = i+1; // not ok
> The BIG mistake is declaration of VARIABLE from wrong position.
No, C++ does not work the way you think it does.
It's not a bug. It would be nice to get a warning, but it's not easy to do
that.