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

            Bug ID: 86562
           Summary: Missing warning (error in C++11) for passing
                    nontrivial object to varargs function via function
                    pointer
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhonghao at pku dot org.cn
  Target Milestone: ---

The code is as follow:

struct Foo {
 Foo() {}
 Foo(const Foo&) {}
};

void f(...);

void g() {
 Foo foo;
 f(foo);
 void (*fp)(...) = f;
 fp(foo);
}

g++ accepts it, but clang++ rejects it:



code1.cpp:10:4: error: cannot pass object of non-trivial type 'Foo' through
      variadic function; call will abort at runtime [-Wnon-pod-varargs]
 f(foo);
   ^
code1.cpp:12:5: error: cannot pass object of non-trivial type 'Foo' through
      variadic function; call will abort at runtime [-Wnon-pod-varargs]
 fp(foo);
    ^
2 errors generated.

Reply via email to