[C++ PATCH] [PR13683] bogus warning about passing non-PODs through ellipsis in sizeof
Giovanni Bajo
giovannibajo@libero.it
Fri Jan 30 14:21:00 GMT 2004
Hi Jason,
as suggested by you, checking for skip_evaluation is enough to fix this PR.
Tested i686-pc-linux-gnu, OK for mainline? OK also for 3.4/3.3, assuming it
applies/works there as well?
Giovanni Bajo
cp/
2004-01-30 Giovanni Bajo <giovannibajo@gcc.gnu.org>
PR c++/13683
* call.c (convert_arg_to_ellipsis): Don't emit a warning if within
a sizeof expression.block
testsuite/
2004-01-30 Giovanni Bajo <giovannibajo@gcc.gnu.org>
PR c++/13683
* g++.dg/template/sizeof6.C: New test.
Index: call.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/call.c,v
retrieving revision 1.454
diff -c -3 -p -r1.454 call.c
*** call.c 21 Jan 2004 20:52:24 -0000 1.454
--- call.c 30 Jan 2004 13:18:50 -0000
*************** convert_arg_to_ellipsis (tree arg)
*** 4127,4140 ****
arg = require_complete_type (arg);
! if (arg != error_mark_node && ! pod_type_p (TREE_TYPE (arg)))
{
/* Undefined behavior [expr.call] 5.2.2/7. We used to just warn
here and do a bitwise copy, but now cp_expr_size will abort if we
! try to do that. */
! warning ("cannot pass objects of non-POD type `%#T' through `...'; \
! call will abort at runtime",
! TREE_TYPE (arg));
arg = call_builtin_trap (TREE_TYPE (arg));
}
--- 4127,4144 ----
arg = require_complete_type (arg);
! if (arg != error_mark_node
! && !pod_type_p (TREE_TYPE (arg)))
{
/* Undefined behavior [expr.call] 5.2.2/7. We used to just warn
here and do a bitwise copy, but now cp_expr_size will abort if we
! try to do that.
! If the call appears in the context of a sizeof expression,
! 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 ("cannot pass objects of non-POD type `%#T' through `...'; "
! "call will abort at runtime", TREE_TYPE (arg));
arg = call_builtin_trap (TREE_TYPE (arg));
}
// { dg-do compile }
// Contributed by Giovanni Bajo <giovannibajo at gcc dot gnu dot org>
// PR c++/13683: bogus warning about passing non-PODs through ellipsis
struct B {};
struct NonPOD : B {};
struct A
{
static int check(...);
static NonPOD GetNonPOD(void);
enum { value = sizeof(A::check(A::GetNonPOD())) };
};
More information about the Gcc-patches
mailing list