This is the mail archive of the
mailing list for the GCC project.
[Bug c++/33475] New warning suggestion: virtual functions called from constructors/destructors
- From: "yuri at tsoft dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Sep 2007 23:37:50 -0000
- Subject: [Bug c++/33475] New warning suggestion: virtual functions called from constructors/destructors
- References: <email@example.com/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #5 from yuri at tsoft dot com 2007-09-19 23:37 -------
I would like to note that this isn't a clear-cut suggestion for the following
* It's impossible to enforce such warning in all cases, only in case of virtual
functions immediately called from constructor/destructor.
* People often use virtual functions from destructors to uninitialize things.
And in many cases it's semi-safe. But it's almost always wrong to call virtual
functions from constructors.
* It probably makes sense to add such warning to Valgrind as well to issue it
based on the run-time analysis
But still such warning in gcc can prevent many errors waiting to happen from
happening. gcc must do as much as possible preventing dangerous coding