https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483
Paolo Carlini changed:
What|Removed |Added
CC||lundberj at gmail dot com
--- Comment #2
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483
--- Comment #20 from Manuel López-Ibáñez 2012-02-09
21:37:38 UTC ---
(In reply to comment #18)
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483#c2
> shows that function calling of object before constructor is bad idea and
> must
> be strong
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483
--- Comment #19 from Jonathan Wakely 2012-02-09
17:04:06 UTC ---
Everyone knows it's a bad idea, and everyone agrees there should be a warning.
Stop going on about it.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483
--- Comment #18 from Lisp2D 2012-02-09 16:59:19 UTC
---
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483#c2
shows that function calling of object before constructor is bad idea and must
be strongly forbidden.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483
--- Comment #17 from Manuel López-Ibáñez 2012-02-09
11:35:27 UTC ---
Clang++ 3.0 warns with -Wuninitialized
/tmp/webcompile/_15338_0.cc:7:5: warning: variable 'a' is uninitialized when
used within its own initialization [-Wuninitialized]
A a(a.i
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483
Jonathan Wakely changed:
What|Removed |Added
Status|UNCONFIRMED |NEW
Last reconfirmed|
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483
--- Comment #15 from Lisp2D 2011-04-07 13:58:38 UTC
---
(In reply to comment #12)
> For the example in comment 2 G++, EDG and Clang++ all accept it without
> warning.
> MSVC rejects it, but is wrong to do so.
The answer is good. Let's talk about
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483
--- Comment #14 from Jonathan Wakely 2011-04-07
13:39:45 UTC ---
(In reply to comment #13)
> (In reply to comment #10)
> > (In reply to comment #9)
> >
> > > No, the variable is in scope after its identifier, so it can be used in
> > > the
> >
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483
--- Comment #13 from Jonathan Wakely 2011-04-07
13:38:11 UTC ---
(In reply to comment #10)
> (In reply to comment #9)
>
> > No, the variable is in scope after its identifier, so it can be used in the
> > initializer expression, e.g.
> >
> > int
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483
--- Comment #12 from Jonathan Wakely 2011-04-07
13:29:43 UTC ---
For the example in comment 2 G++, EDG and Clang++ all accept it without
warning.
MSVC rejects it, but is wrong to do so.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483
--- Comment #11 from Jonathan Wakely 2011-04-07
13:26:16 UTC ---
(In reply to comment #10)
> The answer of question gives the C++ standard. Show me this document.
3.3.1 Point of declaration [basic.scope.decl]
1 The point of declaration for a na
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483
--- Comment #10 from Lisp2D 2011-04-07 13:19:16 UTC
---
(In reply to comment #9)
> 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 o
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483
Jonathan Wakely changed:
What|Removed |Added
Keywords||diagnostic
--- Comment #9 from Jonathan
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483
--- Comment #8 from Dmitry Gorbachev
2011-04-07 06:20:24 UTC ---
There is a call to a non-static member function of the object before
initialization by a constructor. That's undefined behavior. Not a compiler bug.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483
--- Comment #7 from Lisp2D 2011-04-07 04:33:52 UTC
---
The example
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483#c2
shows a compiler bug.
TYPE VARIABLE [ARGUMENT-TO-CONSTRUCT]
The compiler must doing like this:
1. Compile ARGUMENT-TO-CONS
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483
--- Comment #6 from Dmitry Gorbachev
2011-04-07 01:38:53 UTC ---
> there's a limit to how much silliness the compiler can catch,
> at some point you have to just not write silly code ;)
Yes, these reduced fragments look embarrassing.
Of course
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483
--- Comment #5 from Jonathan Wakely 2011-04-06
23:50:38 UTC ---
and PR 18016 but I don't think my patch will catch this
there's a limit to how much silliness the compiler can catch, at some point you
have to just not write silly code ;)
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483
Dmitry Gorbachev changed:
What|Removed |Added
CC||manu at gcc dot gnu.org
--- Comment #4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483
Dmitry Gorbachev changed:
What|Removed |Added
CC||d.g.gorbachev at gmail dot
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483
--- Comment #2 from Lisp2D 2011-04-06 21:15:42 UTC
---
Try the next example, more close to my code:
#include
classA{
public:
inta;
A(intx):a(x){}
intTheInt(){returna;}
};
voidFunc(A&a){
std::clog<<"a.a="<
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48483
--- Comment #1 from Dmitry Gorbachev
2011-04-06 19:20:02 UTC ---
> No warnings and deep stillness.
$ g++ -O -Wuninitialized pr48483.cc
pr48483.cc: In function 'int main()':
pr48483.cc:13:30: warning: 'a.A::b' is used uninitialized in this functi
21 matches
Mail list logo