Bug 80633 - [7/8 Regression] -Wstrict-aliasing false positive
Summary: [7/8 Regression] -Wstrict-aliasing false positive
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 7.1.1
: P3 normal
Target Milestone: 7.2
Assignee: Not yet assigned to anyone
Keywords: diagnostic
Depends on:
Reported: 2017-05-04 20:23 UTC by Casey Carter
Modified: 2017-06-20 18:51 UTC (History)
3 users (show)

See Also:
Known to work:
Known to fail:
Last reconfirmed: 2017-06-19 00:00:00

Repro (sorry, not library-free) (90 bytes, text/plain)
2017-05-04 20:23 UTC, Casey Carter

Note You need to log in before you can comment on or make changes to this bug.
Description Casey Carter 2017-05-04 20:23:46 UTC
Created attachment 41321 [details]
Repro (sorry, not library-free)

gcc 7.1.1 20170504 and 8.0.0 20170504 - but not 6.2/5.4/4.9.4 - incorrectly diagnose this program:

#include <fstream>

extern void f(std::istream&);
std::ifstream ss;
using T = decltype(f(ss)); // warning: dereferencing type-punned pointer will break strict-aliasing rules

when compiling with "gcc -Wstrict-aliasing -O2 -c". The diagnostic is notably not emitted for "decltype(f(std::declval<std::ifstream&>()))".
Comment 1 Jason Merrill 2017-06-19 19:53:03 UTC
I can't reproduce this with 20170619.  Are you still seeing it?
Comment 2 Casey Carter 2017-06-19 20:35:46 UTC
(In reply to Jason Merrill from comment #1)
> I can't reproduce this with 20170619.  Are you still seeing it?

Nope - it appears to have disappeared on trunk.
Comment 3 Jason Merrill 2017-06-20 18:51:05 UTC
Then closing as fixed.