public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58354] New: variadic template ambigous
@ 2013-09-07 12:23 1zeeky at gmail dot com
  2013-09-07 19:41 ` [Bug c++/58354] variadic template ambiguous paolo.carlini at oracle dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: 1zeeky at gmail dot com @ 2013-09-07 12:23 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58354

            Bug ID: 58354
           Summary: variadic template ambigous
           Product: gcc
           Version: 4.8.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 1zeeky at gmail dot com

Created attachment 30761
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30761&action=edit
testcase

I have a templated function, which recursively calls itself.
The stopping criterion is provided via a std::integral_constant<std::size_t>
that gets incremented each iteration and upon a certain value should call an
overload that does not recurse.

There are two requirements to get g++ to claim that the call is ambiguous:
There must be an extra template-parameter that is explicitly specified when
recursing (typename T in the testcase) and variadic templates must be used.
If either is not present, it compiles fine.
If variadic templates are present, but no additional arguments are passed (like
the second parameter for foo (0) in the testcase), it compiles fine.

clang 3.3 compiles this code fine, and given that the mentioned extra
requirements must be met to make the call ambiguous I'm somewhat confident that
it is valid C++.

This is the specific output the attached testcase generates for g++ 4.8.1:

test.cpp: In instantiation of ‘void foo(IndexType<index>, Arguments ...) [with
T = int; long unsigned int index = 0ul; Arguments = {}; IndexType<index> =
std::integral_constant<long unsigned int, 0ul>]’:
test.cpp:15:25:   required from here
test.cpp:11:76: error: call of overloaded ‘foo(IndexType<1ul>, int)’ is
ambiguous
 void foo(IndexType<index>, Arguments...) { foo<T>(IndexType<index + 1>(), 0);
}
                                                                            ^
test.cpp:11:76: note: candidates are:
test.cpp:8:6: note: void foo(IndexType<1ul>, Arguments ...) [with T = int;
Arguments = {int}; IndexType<1ul> = std::integral_constant<long unsigned int,
1ul>]
 void foo(IndexType<1>, Arguments...) { }
      ^
test.cpp:11:6: note: void foo(IndexType<index>, Arguments ...) [with T = int;
long unsigned int index = 1ul; Arguments = {int}; IndexType<index> =
std::integral_constant<long unsigned int, 1ul>]
 void foo(IndexType<index>, Arguments...) { foo<T>(IndexType<index + 1>(), 0);
}
      ^
>From gcc-bugs-return-429211-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Sep 07 12:29:37 2013
Return-Path: <gcc-bugs-return-429211-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 32509 invoked by alias); 7 Sep 2013 12:29:37 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 32472 invoked by uid 48); 7 Sep 2013 12:29:34 -0000
From: "dominiq at lps dot ens.fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/58351] ICE using c_f_pointer subroutine and derived types
Date: Sat, 07 Sep 2013 12:29:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 4.8.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: dominiq at lps dot ens.fr
X-Bugzilla-Status: WAITING
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: cc
Message-ID: <bug-58351-4-lNFqxVjCad@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-58351-4@http.gcc.gnu.org/bugzilla/>
References: <bug-58351-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2013-09/txt/msg00451.txt.bz2
Content-length: 676

http://gcc.gnu.org/bugzilla/show_bug.cgi?idX351

Dominique d'Humieres <dominiq at lps dot ens.fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |burnus at gcc dot gnu.org

--- Comment #2 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
Likely fixed by revision 197053 (r197010 works for me but with a patch).
According to comment #12

> ... by r197053, apparently. Since this looks way too large for backporting,
> I guess it will not be fixed on the 4.7 and 4.8 branches, right?

the fix won't be backported to 4.8.2.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/58354] variadic template ambiguous
  2013-09-07 12:23 [Bug c++/58354] New: variadic template ambigous 1zeeky at gmail dot com
@ 2013-09-07 19:41 ` paolo.carlini at oracle dot com
  2014-11-19 17:21 ` officesamurai at gmail dot com
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-09-07 19:41 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58354

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2013-09-07
     Ever confirmed|0                           |1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/58354] variadic template ambiguous
  2013-09-07 12:23 [Bug c++/58354] New: variadic template ambigous 1zeeky at gmail dot com
  2013-09-07 19:41 ` [Bug c++/58354] variadic template ambiguous paolo.carlini at oracle dot com
@ 2014-11-19 17:21 ` officesamurai at gmail dot com
  2021-01-28 21:00 ` 1zeeky at gmail dot com
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: officesamurai at gmail dot com @ 2014-11-19 17:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58354

Mikhail Kremnyov <officesamurai at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |officesamurai at gmail dot com

--- Comment #1 from Mikhail Kremnyov <officesamurai at gmail dot com> ---
There is a simpler case.

test.cpp:
template <typename T1, typename T2, typename... Types>
void foo(T2, Types...)
{
}

template <typename T1, typename... Types>
void foo(int, Types...)
{
}

int main()
{
  foo<void>(1, 2);
}

Command line:
g++ -std=c++11 test.cpp -o test

Output:
test.cpp: In function ‘int main()’:
test.cpp:13:17: error: call of overloaded ‘foo(int, int)’ is ambiguous
   foo<void>(1, 2);
                 ^
test.cpp:13:17: note: candidates are:
test.cpp:2:6: note: void foo(T2, Types ...) [with T1 = void; T2 = int; Types =
{int}]
 void foo(T2, Types...)
      ^
test.cpp:7:6: note: void foo(int, Types ...) [with T1 = void; Types = {int}]
 void foo(int, Types...)

I tried this with versions 4.8.1, 4.9.1, 4.9.2 - same result.
Clang has no problems with this code.
>From gcc-bugs-return-467542-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Wed Nov 19 17:22:58 2014
Return-Path: <gcc-bugs-return-467542-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 16624 invoked by alias); 19 Nov 2014 17:22:58 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 16605 invoked by uid 48); 19 Nov 2014 17:22:52 -0000
From: "pinskia at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug testsuite/63971] Some of  gcc.target/aarch64/test_frame_*.c tests fail now
Date: Wed, 19 Nov 2014 17:22:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: testsuite
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: pinskia at gcc dot gnu.org
X-Bugzilla-Status: ASSIGNED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: pinskia at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status cf_reconfirmed_on everconfirmed
Message-ID: <bug-63971-4-oP7e8I16Si@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-63971-4@http.gcc.gnu.org/bugzilla/>
References: <bug-63971-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-11/txt/msg02014.txt.bz2
Content-length: 524

https://gcc.gnu.org/bugzilla/show_bug.cgi?idc971

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2014-11-19
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
I have a patch which I will submit this weekend.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/58354] variadic template ambiguous
  2013-09-07 12:23 [Bug c++/58354] New: variadic template ambigous 1zeeky at gmail dot com
  2013-09-07 19:41 ` [Bug c++/58354] variadic template ambiguous paolo.carlini at oracle dot com
  2014-11-19 17:21 ` officesamurai at gmail dot com
@ 2021-01-28 21:00 ` 1zeeky at gmail dot com
  2021-01-29 11:50 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: 1zeeky at gmail dot com @ 2021-01-28 21:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58354

--- Comment #2 from 1zeeky at gmail dot com ---
This has been fixed as of gcc 10.2.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/58354] variadic template ambiguous
  2013-09-07 12:23 [Bug c++/58354] New: variadic template ambigous 1zeeky at gmail dot com
                   ` (2 preceding siblings ...)
  2021-01-28 21:00 ` 1zeeky at gmail dot com
@ 2021-01-29 11:50 ` redi at gcc dot gnu.org
  2021-08-28  1:27 ` pinskia at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: redi at gcc dot gnu.org @ 2021-01-29 11:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58354

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |10.2
           Keywords|                            |rejects-valid
                 CC|                            |jason at gcc dot gnu.org

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed by r11-1571 and r10-8343: Refinements to "more constrained".

Jason, was the change to tsubst_pack_expansion a drive-by fix that resolved
this bug?

            * pt.c (tsubst_pack_expansion): Fix getting a type parameter
            pack.


The rest of the commit is related to constrained functions, which aren't
relevant here.

Should we add this testcase before closing the bug?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/58354] variadic template ambiguous
  2013-09-07 12:23 [Bug c++/58354] New: variadic template ambigous 1zeeky at gmail dot com
                   ` (3 preceding siblings ...)
  2021-01-29 11:50 ` redi at gcc dot gnu.org
@ 2021-08-28  1:27 ` pinskia at gcc dot gnu.org
  2021-08-28  1:54 ` pinskia at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-28  1:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58354

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rbock at eudoxos dot de

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 77449 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/58354] variadic template ambiguous
  2013-09-07 12:23 [Bug c++/58354] New: variadic template ambigous 1zeeky at gmail dot com
                   ` (4 preceding siblings ...)
  2021-08-28  1:27 ` pinskia at gcc dot gnu.org
@ 2021-08-28  1:54 ` pinskia at gcc dot gnu.org
  2021-08-28  1:54 ` pinskia at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-28  1:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58354

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |lumosimann at gmail dot com

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 89085 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/58354] variadic template ambiguous
  2013-09-07 12:23 [Bug c++/58354] New: variadic template ambigous 1zeeky at gmail dot com
                   ` (5 preceding siblings ...)
  2021-08-28  1:54 ` pinskia at gcc dot gnu.org
@ 2021-08-28  1:54 ` pinskia at gcc dot gnu.org
  2021-08-28  1:54 ` pinskia at gcc dot gnu.org
  2023-07-07  7:19 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-28  1:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58354

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |oknenavin at outlook dot com

--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 90642 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/58354] variadic template ambiguous
  2013-09-07 12:23 [Bug c++/58354] New: variadic template ambigous 1zeeky at gmail dot com
                   ` (6 preceding siblings ...)
  2021-08-28  1:54 ` pinskia at gcc dot gnu.org
@ 2021-08-28  1:54 ` pinskia at gcc dot gnu.org
  2023-07-07  7:19 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-28  1:54 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58354

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vexocide at gmail dot com

--- Comment #7 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
*** Bug 59135 has been marked as a duplicate of this bug. ***

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Bug c++/58354] variadic template ambiguous
  2013-09-07 12:23 [Bug c++/58354] New: variadic template ambigous 1zeeky at gmail dot com
                   ` (7 preceding siblings ...)
  2021-08-28  1:54 ` pinskia at gcc dot gnu.org
@ 2023-07-07  7:19 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07  7:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58354

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2023-07-07  7:19 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-07 12:23 [Bug c++/58354] New: variadic template ambigous 1zeeky at gmail dot com
2013-09-07 19:41 ` [Bug c++/58354] variadic template ambiguous paolo.carlini at oracle dot com
2014-11-19 17:21 ` officesamurai at gmail dot com
2021-01-28 21:00 ` 1zeeky at gmail dot com
2021-01-29 11:50 ` redi at gcc dot gnu.org
2021-08-28  1:27 ` pinskia at gcc dot gnu.org
2021-08-28  1:54 ` pinskia at gcc dot gnu.org
2021-08-28  1:54 ` pinskia at gcc dot gnu.org
2021-08-28  1:54 ` pinskia at gcc dot gnu.org
2023-07-07  7:19 ` rguenth at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).