Bug 1544675 - False positive from -Weffc++ in gcc 8
Summary: False positive from -Weffc++ in gcc 8
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Dave Malcolm
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-02-13 09:16 UTC by Tom Hughes
Modified: 2018-02-13 21:52 UTC (History)
10 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-02-13 21:52:11 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
Test case (214 bytes, text/x-csrc)
2018-02-13 09:16 UTC, Tom Hughes
no flags Details


Links
System ID Private Priority Status Summary Last Updated
GNU Compiler Collection 84364 0 None None None 2018-02-13 15:16:49 UTC

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.


Note You need to log in before you can comment on or make changes to this bug.