Bug 86562 - Missing warning (error in C++11) for passing nontrivial object to varargs function via function pointer
Summary: Missing warning (error in C++11) for passing nontrivial object to varargs fun...
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 9.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: accepts-invalid, diagnostic
Depends on:
Blocks:
 
Reported: 2018-07-18 05:27 UTC by zhonghao
Modified: 2018-07-18 14:03 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description zhonghao 2018-07-18 05:27:33 UTC
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.
Comment 1 Jonathan Wakely 2018-07-18 12:03:07 UTC
Not a bug. The standard says passing non-trivial types through varargs is "conditionally-supported" so an implementation can either support it, or reject it with a diagnostic.

GCC supports it, Clang doesn't.
Comment 2 Eric Gallager 2018-07-18 13:54:30 UTC
I think this is actually a dup of bug 64867

*** This bug has been marked as a duplicate of bug 64867 ***
Comment 3 Jonathan Wakely 2018-07-18 14:03:35 UTC
I disagree. This report states "g++ accepts it, but clang++ rejects it" and that is not a bug, it's a feature. If a diagnostic is desired it can be requested with -Wconditionally-supported or -Werror-conditionally-supported

64867 says "It would be nice to have a distinct warning flag for this feature" which is different.

This bug is invalid.