This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
cc1plus feature request: -Wglobal-non-POD, -Wfunction-static-non-POD
- To: gcc-bugs at gcc dot gnu dot org
- Subject: cc1plus feature request: -Wglobal-non-POD, -Wfunction-static-non-POD
- From: Marco Franzen <Marco dot Franzen at Thyron dot com>
- Date: Thu, 24 Aug 2000 14:36:57 +0100
- Organization: Thyron Limited, UK
I hope this is the right forum for this. If not, please forgive and redirect
me kindly.
(1) When converting a C++ library so that it can be called from non-C++ code
(or to ensure that the code being worked on stays callable from non-C++
code), it is necessary to find all places where global or class-static
non-POD objects are defined.
Even with a C++ main(), there will always be platforms where code like
that would not work with shared libraries.
(2) If not anyway for the same reason, especially in analysing subtle
destruction order problems at program shutdown, it can be helpful to
find function-static non-POD objects as well.
(=>) It would be nice to have two additional warning switches for
finding those object definitions. That should be very easy to implement:
The compiler needs to emit special code anyway to call constructors before
and destructors after main for global or class-static non-PODs. Also, for
function-static non-PODs, special treatment is necessary anyway to make
sure the destructor is called before that of the previously constructed
object of either category. These two places could simply issue the warning
if the corresponding switch is on.
The new warning switches should probably be off by default, even with -W
and -Wall. (Except maybe for platforms where shared libraries cannot
handle this, possibly also dependend on -fpic, etc.)
Marco
[this is not confidential; please ignore the appended clause]
-----------------------------------------------------------------
This email is confidential and intended solely for the use of the
individual to whom it is addressed.
Any views or opinions presented are solely those of the author
and do not necessarily represent those of Thyron Limited.
If you are not the intended recipient then please be advised
that you have received this email in error and that any use,
dissemination, forwarding, printing or copying of this email
is strictly prohibited.
If you have received this email in error, please notify the
Thyron IT Administrator on +44 (0)1923 236 050 or
send an email to mail-admin@thyron.com.
Thank You