Bug#246640: g++-3.3: Spurious ctor/dtor warnings (fixed)
Package: g++-3.3
Version: 1:3.3.3-6
Severity: normal
Tags: patch
-- System Information:
Debian Release: testing/unstable
APT prefers testing
APT policy: (500, 'testing')
Architecture: i386 (i686)
Kernel: Linux 2.6.5
Locale: LANG=en_US, LC_CTYPE=en_US
Versions of packages g++-3.3 depends on:
ii gcc-3.3 1:3.3.3-6 The GNU C compiler
ii gcc-3.3-base 1:3.3.3-6 The GNU Compiler Collection (base
ii libc6 2.3.2.ds1-11 GNU C Library: Shared libraries an
ii libstdc++5-3.3-dev 1:3.3.3-6 The GNU Standard C++ Library v3 (d
-- no debconf information
This patch fixes two issues related to ctor/dtor warnings:
1. -Wctor-dtor-privacy often gives false positives. Remove it from -Wall.
This was done in upstream for 3.4. Note I have not updated the manpage
with this patch.
2. -Wnon-virtual-dtor gives false positives when the dtor is declared
private and no friend classes are declared. This is acknowledged by
upstream and will presumedly be patched very shortly (but I don't know
which branch(es) will get this fix). See GCC PR 15214.
diff -Naur gcc-3.3-3.3.3ds6.orig/debian/README.Debian gcc-3.3-3.3.3ds6/debian/README.Debian
--- gcc-3.3-3.3.3ds6.orig/debian/README.Debian 2004-04-29 22:30:19.000000000 -0700
+++ gcc-3.3-3.3.3ds6/debian/README.Debian 2004-04-29 22:43:36.000000000 -0700
@@ -59,6 +59,12 @@
hppa-libjava:
Enable libjava support for hppa
+wall_no_ctor_dtor_privacy:
+ Remove -Wctor-dtor-privacy from -Wall
+
+relax_nonvdtor:
+ Do not warn if dtor is private and class has no friends
+
test-summary:
add libstdc++-v3's check summary to the test summary
diff -Naur gcc-3.3-3.3.3ds6.orig/debian/patches/relax_nonvdtor.dpatch gcc-3.3-3.3.3ds6/debian/patches/relax_nonvdtor.dpatch
--- gcc-3.3-3.3.3ds6.orig/debian/patches/relax_nonvdtor.dpatch 1969-12-31 16:00:00.000000000 -0800
+++ gcc-3.3-3.3.3ds6/debian/patches/relax_nonvdtor.dpatch 2004-04-29 22:40:17.000000000 -0700
@@ -0,0 +1,48 @@
+#! /bin/sh -e
+
+# DP: Do not warn if dtor is private and class has no friends
+
+dir=
+if [ $# -eq 3 -a "$2" = '-d' ]; then
+ pdir="-d $3"
+ dir="$3/"
+elif [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+case "$1" in
+ -patch)
+ patch $pdir -f --no-backup-if-mismatch -p0 < $0
+ #cd ${dir}gcc && autoconf
+ ;;
+ -unpatch)
+ patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
+ #rm ${dir}gcc/configure
+ ;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+esac
+exit 0
+
+--- gcc/cp/class.c.orig 2004-04-29 17:35:20.000000000 -0700
++++ gcc/cp/class.c 2004-04-29 17:36:56.000000000 -0700
+@@ -5437,7 +5437,17 @@
+
+ if (warn_nonvdtor && TYPE_POLYMORPHIC_P (t) && TYPE_HAS_DESTRUCTOR (t)
+ && DECL_VINDEX (TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (t), 1)) == NULL_TREE)
+- warning ("`%#T' has virtual functions but non-virtual destructor", t);
++ {
++ tree dtor = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (t), 1);
++
++ /* Warn only if the dtor is non-private or the class has friends */
++ if (!TREE_PRIVATE (dtor) ||
++ (CLASSTYPE_FRIEND_CLASSES (t) ||
++ DECL_FRIENDLIST (TYPE_MAIN_DECL (t))))
++ {
++ warning ("%#T' has virtual functions but non-virtual destructor", t);
++ }
++ }
+
+ complete_vars (t);
+
diff -Naur gcc-3.3-3.3.3ds6.orig/debian/patches/wall_no_ctor_dtor_privacy.dpatch gcc-3.3-3.3.3ds6/debian/patches/wall_no_ctor_dtor_privacy.dpatch
--- gcc-3.3-3.3.3ds6.orig/debian/patches/wall_no_ctor_dtor_privacy.dpatch 1969-12-31 16:00:00.000000000 -0800
+++ gcc-3.3-3.3.3ds6/debian/patches/wall_no_ctor_dtor_privacy.dpatch 2004-04-29 22:40:18.000000000 -0700
@@ -0,0 +1,37 @@
+#! /bin/sh -e
+
+# DP: Remove -Wctor-dtor-privacy from -Wall
+
+dir=
+if [ $# -eq 3 -a "$2" = '-d' ]; then
+ pdir="-d $3"
+ dir="$3/"
+elif [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+case "$1" in
+ -patch)
+ patch $pdir -f --no-backup-if-mismatch -p0 < $0
+ #cd ${dir}gcc && autoconf
+ ;;
+ -unpatch)
+ patch $pdir -f --no-backup-if-mismatch -R -p0 < $0
+ #rm ${dir}gcc/configure
+ ;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+esac
+exit 0
+
+--- gcc/c-opts.c.orig 2004-04-29 17:37:08.000000000 -0700
++++ gcc/c-opts.c 2004-04-29 17:37:32.000000000 -0700
+@@ -721,7 +721,6 @@
+ else
+ {
+ /* C++-specific warnings. */
+- warn_ctor_dtor_privacy = on;
+ warn_nonvdtor = on;
+ warn_reorder = on;
+ warn_nontemplate_friend = on;
diff -Naur gcc-3.3-3.3.3ds6.orig/debian/rules.patch gcc-3.3-3.3.3ds6/debian/rules.patch
--- gcc-3.3-3.3.3ds6.orig/debian/rules.patch 2004-04-29 22:30:19.000000000 -0700
+++ gcc-3.3-3.3.3ds6/debian/rules.patch 2004-04-29 22:29:17.000000000 -0700
@@ -18,6 +18,10 @@
gccbug libtool-rpath \
hppa-libffi hppa-libjava \
+ifeq ($(with_cxx),yes)
+ debian_patches += wall_no_ctor_dtor_privacy relax_nonvdtor
+endif
+
debian_patches += test-summary
ifeq ($(with_java),yes)
Reply to: