This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/64867] warning for passing non-POD to varargs function


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64867

--- Comment #4 from Tom Tromey <tromey at gcc dot gnu.org> ---
Thanks, I'll give it a try.

Here's my test case FWIW and a short demo showing what clang does:

pokyo. cat q.cc
#include <stdarg.h>

class ConstUTF8CharsZ
{
    const char *mData;

  public:
    ConstUTF8CharsZ() : mData(0)
    {
    }

    explicit ConstUTF8CharsZ(const char *aBytes)
      : mData(aBytes)
    {
    }

    const void *get() const { return mData; }

    const char *c_str() const { return mData; }

    operator bool() const { return mData != 0; }
};


void zzz(const char *x, ...) {
}

void m(const char *m) {
  ConstUTF8CharsZ cu(m);
  zzz(m, cu);
}
pokyo. clang++ q.cc
q.cc:30:10: error: cannot pass object of non-POD type 'ConstUTF8CharsZ' through
      variadic function; call will abort at runtime [-Wnon-pod-varargs]
  zzz(m, cu);
         ^
1 error generated.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]