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++/70844] New: spurious -Wuseless-cast warning with inherited constructors


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.

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