[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#460264: g++-4.2: Please make it possible to make the "cannot pass objects of non-POD type ..." warning into an error

Package: g++-4.2
Version: 4.2.2-5
Severity: wishlist

The warning generated at gcc/cp/call.c:4548 doesn't have a warning type 
associated with it, so there's no way to turn this warning into an

This is a very serious warning, as indicated by the fact that it tells
you the call will abort at runtime.  If a user doesn't notice this
warning, debugging the problem is very difficult.

If one could add something like -Werror=pass-non-POD to the gcc options,
then this would save quite a few headaches here :)

Maybe something along the lines of...

--- gcc-20071008.orig/gcc/c.opt	2007-09-01 16:49:07.000000000 -0400
+++ gcc-20071008/gcc/c.opt	2008-01-11 10:09:57.000000000 -0500
@@ -330,6 +330,10 @@
 C ObjC C++ ObjC++ Var(warn_parentheses)
 Warn about possibly missing parentheses
+C++ Var(warn_pass_non_pod)
+Warn about passing non-POD types through '...'
 C++ ObjC++ Var(warn_pmf2ptr) Init(1)
 Warn when converting the type of pointers to member functions
diff -urN gcc-20071008.orig/gcc/cp/call.c gcc-20071008/gcc/cp/call.c
--- gcc-20071008.orig/gcc/cp/call.c	2007-09-13 08:57:52.000000000 -0400
+++ gcc-20071008/gcc/cp/call.c	2008-01-11 10:09:53.000000000 -0500
@@ -4545,7 +4545,7 @@
         there is no need to emit a warning, since the expression won't be
         evaluated. We keep the builtin_trap just as a safety check.  */
       if (!skip_evaluation)
-	warning (0, "cannot pass objects of non-POD type %q#T through %<...%>; "
+	warning (OPT_Wpass_non_pod, "cannot pass objects of non-POD type %q#T through %<...%>; "
                 "call will abort at runtime", TREE_TYPE (arg));
       arg = call_builtin_trap ();
       arg = build2 (COMPOUND_EXPR, integer_type_node, arg,

-- System Information:
Debian Release: lenny/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.23-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_CA.UTF-8, LC_CTYPE=en_CA.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages g++-4.2 depends on:
ii  gcc-4.2                       4.2.2-5    The GNU C compiler
ii  gcc-4.2-base                  4.2.2-5    The GNU Compiler Collection (base 
ii  libc6                         2.7-5      GNU C Library: Shared libraries
ii  libstdc++6-4.2-dev            4.2.2-5    The GNU Standard C++ Library v3 (d

g++-4.2 recommends no packages.

-- no debconf information

Reply to: