Bug 1802608 - g++ rejects a valid code
Summary: g++ rejects a valid code
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Developer Toolset
Classification: Red Hat
Component: gcc
Version: DTS 9.0 RHEL 7
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: alpha
: 9.1
Assignee: Marek Polacek
QA Contact: Alexandra Petlanová Hájková
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-02-13 14:32 UTC by Joe Wright
Modified: 2023-10-06 19:11 UTC (History)
15 users (show)

Fixed In Version: devtoolset-9-gcc-9.3.1-1.el7
Doc Type: Bug Fix
Doc Text:
Cause: A mismatch in template argument deduction. Consequence: Valid C++ code would fail to compile. Fix: Don't reduce the template level of template parameters when performing template argument deduction substitution. Result: The code compiles correctly.
Clone Of:
Environment:
Last Closed: 2020-05-26 06:07:39 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
GNU Compiler Collection 90505 0 P2 RESOLVED [9 Regression] g++ rejects valid code 2020-08-18 13:23:17 UTC
GNU Compiler Collection 92221 0 P3 RESOLVED [9/10 Regression] template argument deduction/substitution failed after "Implement P0846R0, ADL and function templates" 2020-08-18 13:23:17 UTC
Red Hat Product Errata RHSA-2020:2274 0 None None None 2020-05-26 06:07:46 UTC

Description Joe Wright 2020-02-13 14:32:08 UTC
Description of problem:

=== Console ===
~/tmp$ g++-9.1.0 -c test.cpp
test.cpp: In member function ‘void S<T>::bar()’:
test.cpp:11:20: error: no matching function for call to ‘S<T>::foo<void>(int)’
   11 |         foo<void>(1);
      |                    ^
test.cpp:5:17: note: candidate: ‘template<class T> template<class U, class V> static void S<T>::foo(V)’
    5 |     static void foo(V)
      |                 ^~~
test.cpp:5:17: note:   template argument deduction/substitution failed:
test.cpp:11:20: note:   mismatched types ‘V’ and ‘int’
   11 |         foo<void>(1);
      |       
===

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

How reproducible:
=== test.cpp ===
template <class T>
struct S
{
    template <class U, class V>
    static void foo(V)
    {
    }
    
    void bar()
    {
        foo<void>(1);
    }
};
===

Steps to Reproduce:
1.See above
2.
3.

Actual results:
See description

Expected results:


Additional info:

This is reported upstream in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90505 and https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92221 

This also appears to be a regressiopn from a previous fix: https://gcc.gnu.org/viewcvs/gcc?view=revision&revision=265734

Comment 2 Marek Polacek 2020-02-13 15:02:28 UTC
Thanks for the report, I will restart my work on the fix next week (I'm on PTO today and Friday).

Also fixing the component.

Comment 4 Marek Polacek 2020-03-04 13:01:17 UTC
Fixed upstream: https://gcc.gnu.org/g:6b3302da9ef26aa11940f8c0dc92bec19e15c09b

Comment 5 Marek Polacek 2020-03-04 23:53:24 UTC
Fixed in gcc 9 too: https://gcc.gnu.org/g:581825efc30ce79d86dfb0ebf378913fdec44adf

Comment 16 errata-xmlrpc 2020-05-26 06:07:39 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2020:2274


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