This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/64867] warning for passing non-POD to varargs function
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 31 Jan 2015 02:37:20 +0000
- Subject: [Bug c++/64867] warning for passing non-POD to varargs function
- Auto-submitted: auto-generated
- References: <bug-64867-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64867
--- Comment #11 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Tom Tromey from comment #9)
> However my belief is that because this class has a user-provided
> default constructor, it is not trivial.
True, but ...
> I tested this by adding "#include <type_traits>" and then
>
> static_assert(!std::is_trivial<ConstUTF8CharsZ>::value, "whoops");
That's the wrong thing to assert:
Passing a potentially-evaluated argument of class type (Clause 9)
having a non-trivial copy constructor, a non-trivial move constructor,
or a non-trivial destructor, with no corresponding parameter, is
conditionally-supported with implementation-defined semantics.
Your type has a trivial copy constructor and trivial move constructor and
trivial destructor, so passing it to a varargs function is well-defined.
Give it a non-trivial destructor and you get a warning:
cs.cc: In function âvoid m(const char*)â:
cs.cc:33:12: warning: passing objects of non-trivially-copyable type âclass
ConstUTF8CharsZâ through â...â is conditionally supported
[-Wconditionally-supported]
zzz(m, cu);
^