Bug 1544675

Summary: False positive from -Weffc++ in gcc 8
Product: [Fedora] Fedora Reporter: Tom Hughes <tom>
Component: gccAssignee: Dave Malcolm <dmalcolm>
Status: CLOSED UPSTREAM QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: aoliva, davejohansen, dmalcolm, fweimer, jakub, jwakely, law, mpolacek, msebor, nickc
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-13 21:52:11 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
Test case none

Description Tom Hughes 2018-02-13 09:16:07 UTC
Created attachment 1395251 [details]
Test case

Description of problem:

It seems gcc 8 is warning about some code that doesn't warn in gcc 7 and
which appears to be doing exactly what the warning says to do.

Specifically it warns that operator= should "return a reference to *this" which is exactly what it appears to be doing.

Version-Release number of selected component (if applicable):

gcc-c++-8.0.1-0.13.fc28.x86_64

Steps to Reproduce:
1. Compile attached test case with "g++ -Weffc++ -Werror -o reference reference.cpp"

Actual results:

reference.cpp:6:13: error: ‘operator=’ should return a reference to ‘*this’ [-Werror=effc++]
     return *this;
             ^~~~
cc1plus: all warnings being treated as errors

Expected results:

No warning.

Additional info:

Found during mass rebuild of wagyu - have removed -Werror there so this isn't blocking anything.

Comment 1 Dave Malcolm 2018-02-13 15:16:50 UTC
Thanks.  I've reported this upstream as
  https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84364

Comment 2 Jonathan Wakely 2018-02-13 18:04:04 UTC
(In reply to Tom Hughes from comment #0)
> Found during mass rebuild of wagyu - have removed -Werror there so this
> isn't blocking anything.

I'd also remove -Weffc++ unless the package specifically wants outdated advice from the 1990s.

Comment 3 Dave Malcolm 2018-02-13 21:52:11 UTC
Jakub fixed this upstream; marking this one as closed.