Bug 87748 - [8/9 Regression] G++-8 treats SFINAE as error
Summary: [8/9 Regression] G++-8 treats SFINAE as error
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 8.1.1
: P3 normal
Target Milestone: 8.3
Assignee: Not yet assigned to anyone
Keywords: rejects-valid
Depends on:
Reported: 2018-10-25 11:03 UTC by Tim Janik
Modified: 2018-10-26 12:36 UTC (History)
2 users (show)

See Also:
Known to work: 7.3.0
Known to fail: 8.2.0, 9.0
Last reconfirmed: 2018-10-25 00:00:00

g++-8 SFINAE Error Test Case (1.01 KB, text/x-csrc)
2018-10-25 11:03 UTC, Tim Janik

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Janik 2018-10-25 11:03:05 UTC
Created attachment 44897 [details]
g++-8 SFINAE Error Test Case

The following (reduced) code example uses SFINAE to discern argument types in a visitor pattern. The original bug report is here: https://github.com/tim-janik/beast/issues/72#issuecomment-432874963

It works well under clang-6 and g++-7.3. With g++-8.1.1 (and reportedly g++-8.2.1) a template substitution failure during a method presence check on std::string is promoted to an error, even though a std::false_type substitution variant exists that should be picked up instead.

Not only do other compiler (versions) compile this correctly, but duplicating a seemingly unrelated static_assert in the code also "remedies" the g++-8 treatment of the failure as error, tested via -DWITHASSERT below.


$ g++ --version
g++ (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0

$ g++ -std=gnu++14 -Wall -O2 aidavisit.cc && ./a.out 
visit_string: some_string="A std::string"


$ g++ --version
g++ (GCC) 8.1.1 20180712 (Red Hat 8.1.1-5)

$ g++ -std=gnu++14 -Wall -O2 aidavisit.cc && ./a.out 
aidavisit.cc:19:77: error: 'class std::__cxx11::basic_string<char>' has no member named '__aida_visit__'

$ g++ -std=gnu++14 -Wall -O2 aidavisit.cc -DWITHASSERT && ./a.out 
visit_string: some_string="A std::string"
Comment 1 Jonathan Wakely 2018-10-25 11:13:36 UTC
This regressed with r258824

            PR c++/78489 - wrong SFINAE behavior.
            PR c++/84489
            * pt.c (type_unification_real): Don't defer substitution failure.