https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70844
Bug ID: 70844
Summary: spurious -Wuseless-cast warning with inherited
constructors
Product: gcc
Version: 6.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: danny+gcc at nerdcruft dot net
Target Milestone: ---
Created attachment 38359
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=38359&action=edit
useless-cast inherited constructor test case
When using -Wuseless-cast with C++11 code under gcc-6.1.0 an inherited
constructor will trigger useless-cast warnings on synthesized constructors
(with at least arithmetic types) even if the parameters are of the correct
type.
Attached a reduced test case.
Behaviour can be triggered as follows, with example output:
danny@steve /tmp $ g++ -std=c++11 -Wuseless-cast -c -o test.o test.cpp
test.cpp: In constructor ‘derived::derived(int)’:
test.cpp:6:17: warning: useless cast to type ‘int’ [-Wuseless-cast]
using base::base;
^~~~
test.cpp: In function ‘void func(int)’:
test.cpp:11:17: note: synthesized method ‘derived::derived(int)’ first required
here
derived d (i);
^
This behaviour is observed in gcc-6.0.0 and gcc-6.1.0, but not gcc-5.3.0.