public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/43382]  New: Internal error on C++0x code
@ 2010-03-15 20:14 chris at bubblescope dot net
  2010-03-15 23:56 ` [Bug c++/43382] ICE " paolo dot carlini at oracle dot com
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: chris at bubblescope dot net @ 2010-03-15 20:14 UTC (permalink / raw)
  To: gcc-bugs

The following code causes an assert on a recent svn g++, with -std=c++0x. On
g++ 4.4 it produces an error. I believe the code to be valid, but am not 100%
positive.

#include <vector>

struct Range
{
        int lb;
        int ub;
        Range(int i, int j) : lb(i), ub(j) {}
        Range(const Range& r) = default;
        Range() = default;
};

template<class T>
T deref(const T& t)
{ return t; }

template <class T, template <typename T, typename...> class Cont,
          class... Args>
auto
deref(const Cont<T>& u, int i, Args... args)
-> decltype(deref(u[i], args...))
{ deref(u[i], args...); }

template <class T, template <typename T, typename...> class Cont,
          class... Args>
auto
deref(const Cont<T>& u, Range r, Args... args)
-> Cont<decltype(deref(u[0], args...))>
{
        typedef decltype(deref(u[0], args...)) member;
        Cont<member> retval;
        for(int i = r.lb; i <= r.ub; ++i)
        {
                retval.push_back(deref(u[i], args...));
        } 
        return retval;
}



int main(void)
{
        std::vector<std::vector<std::vector<int>>> v;
        int i = deref(v, 1,2,3);
        std::vector<int> j = deref(v, 1, Range(1,2), 3);
}


-- 
           Summary: Internal error on C++0x code
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: chris at bubblescope dot net


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


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

* [Bug c++/43382] ICE on C++0x code
  2010-03-15 20:14 [Bug c++/43382] New: Internal error on C++0x code chris at bubblescope dot net
@ 2010-03-15 23:56 ` paolo dot carlini at oracle dot com
  2010-03-16  8:39 ` chris at bubblescope dot net
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-03-15 23:56 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from paolo dot carlini at oracle dot com  2010-03-15 23:56 -------
If you could reduce it somewhat, it would be appreciated.

Let's add Jason in CC.


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jason at gcc dot gnu dot org
            Summary|Internal error on C++0x code|ICE on C++0x code


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


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

* [Bug c++/43382] ICE on C++0x code
  2010-03-15 20:14 [Bug c++/43382] New: Internal error on C++0x code chris at bubblescope dot net
  2010-03-15 23:56 ` [Bug c++/43382] ICE " paolo dot carlini at oracle dot com
@ 2010-03-16  8:39 ` chris at bubblescope dot net
  2010-03-16 10:28 ` paolo dot carlini at oracle dot com
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: chris at bubblescope dot net @ 2010-03-16  8:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from chris at bubblescope dot net  2010-03-16 08:38 -------
Reduced testcase:

template<class T>
struct Container
{ T f() const; };

template<class T>
T deref(const T& t)
{ return t; }


template <class T, class... Args>
auto
deref(const T& u, int r, Args... args)
-> decltype(deref(u.f(), args...))
{ return deref(u.f(), args...); }

int main(void)
{
    Container<Container<int>> v;
    deref(v,1,2);
}


-- 


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


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

* [Bug c++/43382] ICE on C++0x code
  2010-03-15 20:14 [Bug c++/43382] New: Internal error on C++0x code chris at bubblescope dot net
  2010-03-15 23:56 ` [Bug c++/43382] ICE " paolo dot carlini at oracle dot com
  2010-03-16  8:39 ` chris at bubblescope dot net
@ 2010-03-16 10:28 ` paolo dot carlini at oracle dot com
  2010-03-16 11:51 ` rguenth at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: paolo dot carlini at oracle dot com @ 2010-03-16 10:28 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from paolo dot carlini at oracle dot com  2010-03-16 10:27 -------
Thanks Chris.


-- 

paolo dot carlini at oracle dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-03-16 10:27:59
               date|                            |


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


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

* [Bug c++/43382] ICE on C++0x code
  2010-03-15 20:14 [Bug c++/43382] New: Internal error on C++0x code chris at bubblescope dot net
                   ` (2 preceding siblings ...)
  2010-03-16 10:28 ` paolo dot carlini at oracle dot com
@ 2010-03-16 11:51 ` rguenth at gcc dot gnu dot org
  2010-05-26  4:59 ` [Bug c++/43382] [C++0x] ICE with auto return type and variadic templates jason at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2010-03-16 11:51 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 411 bytes --]



------- Comment #4 from rguenth at gcc dot gnu dot org  2010-03-16 11:51 -------
4.4 ICEs for me:

> g++-4.4 -S t.C -std=c++0x
t.C: In function ‘int main()’:
t.C:12: internal compiler error: in tsubst_copy, at cp/pt.c:10077
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://bugs.opensuse.org/> for instructions.


-- 


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


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

* [Bug c++/43382] [C++0x] ICE with auto return type and variadic templates
  2010-03-15 20:14 [Bug c++/43382] New: Internal error on C++0x code chris at bubblescope dot net
                   ` (3 preceding siblings ...)
  2010-03-16 11:51 ` rguenth at gcc dot gnu dot org
@ 2010-05-26  4:59 ` jason at gcc dot gnu dot org
  2010-05-26 15:00 ` jason at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-05-26  4:59 UTC (permalink / raw)
  To: gcc-bugs



-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jason at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2010-03-16 10:27:59         |2010-05-26 04:59:29
               date|                            |


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


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

* [Bug c++/43382] [C++0x] ICE with auto return type and variadic templates
  2010-03-15 20:14 [Bug c++/43382] New: Internal error on C++0x code chris at bubblescope dot net
                   ` (4 preceding siblings ...)
  2010-05-26  4:59 ` [Bug c++/43382] [C++0x] ICE with auto return type and variadic templates jason at gcc dot gnu dot org
@ 2010-05-26 15:00 ` jason at gcc dot gnu dot org
  2010-05-26 15:19 ` jason at gcc dot gnu dot org
  2010-05-26 17:15 ` jason at gcc dot gnu dot org
  7 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-05-26 15:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from jason at gcc dot gnu dot org  2010-05-26 15:00 -------
Subject: Bug 43382

Author: jason
Date: Wed May 26 15:00:02 2010
New Revision: 159873

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159873
Log:
        PR c++/43382
        * pt.c (fn_type_unification): Don't get confused by recursive
        unification.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/variadic101.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug c++/43382] [C++0x] ICE with auto return type and variadic templates
  2010-03-15 20:14 [Bug c++/43382] New: Internal error on C++0x code chris at bubblescope dot net
                   ` (5 preceding siblings ...)
  2010-05-26 15:00 ` jason at gcc dot gnu dot org
@ 2010-05-26 15:19 ` jason at gcc dot gnu dot org
  2010-05-26 17:15 ` jason at gcc dot gnu dot org
  7 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-05-26 15:19 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from jason at gcc dot gnu dot org  2010-05-26 15:19 -------
Subject: Bug 43382

Author: jason
Date: Wed May 26 15:18:46 2010
New Revision: 159875

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159875
Log:
        PR c++/43382
        * pt.c (fn_type_unification): Don't get confused by recursive
        unification.

Added:
    branches/gcc-4_5-branch/gcc/testsuite/g++.dg/cpp0x/variadic101.C
Modified:
    branches/gcc-4_5-branch/gcc/cp/ChangeLog
    branches/gcc-4_5-branch/gcc/cp/pt.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog


-- 


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


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

* [Bug c++/43382] [C++0x] ICE with auto return type and variadic templates
  2010-03-15 20:14 [Bug c++/43382] New: Internal error on C++0x code chris at bubblescope dot net
                   ` (6 preceding siblings ...)
  2010-05-26 15:19 ` jason at gcc dot gnu dot org
@ 2010-05-26 17:15 ` jason at gcc dot gnu dot org
  7 siblings, 0 replies; 10+ messages in thread
From: jason at gcc dot gnu dot org @ 2010-05-26 17:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from jason at gcc dot gnu dot org  2010-05-26 17:15 -------
Fixed for 4.5.1.


-- 

jason at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.5.1


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


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

* [Bug c++/43382] [C++0x] ICE with auto return type and variadic templates
       [not found] <bug-43382-4@http.gcc.gnu.org/bugzilla/>
@ 2020-04-20 22:56 ` cvs-commit at gcc dot gnu.org
  0 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-04-20 22:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Patrick Palka <ppalka@gcc.gnu.org>:

https://gcc.gnu.org/g:a3a4f6be0c7ac1536c4d1def14217840b04dd488

commit r10-7835-ga3a4f6be0c7ac1536c4d1def14217840b04dd488
Author: Patrick Palka <ppalka@redhat.com>
Date:   Mon Apr 20 18:34:00 2020 -0400

    c++: Recursive unification with packs and explicit targs [PR94628]

    This PR seems to be similar to PR c++/43382, except that the recursive call
to
    the variadic function with trailing return type in this testcase is
additionally
    given some explicit template arguments.

    In the first testcase below, when resolving the recursive call to 'select',
    fn_type_unification first substitutes in the call's explicit template
arguments
    before doing unification, and so during this substitution the template
argument
    pack for Args is incomplete.

    Since the pack is incomplete, the substitution of 'args...' in the trailing
    return type decltype(f(args...)) is handled by the unsubstituted_packs case
of
    tsubst_pack_expansion.  But the handling of this case happens _before_ we
reset
    local_specializations, and so the substitution ends up reusing the old
binding
    for 'args' from local_specializations rather than building a new one.

    This patch fixes this issue by setting up local_specializations sooner in
    tsubst_pack_expansion, before the handling of the unsubstituted_packs case.
    It also adds a new policy to local_specialization_stack so that we could
use the
    class here to conditionally replace local_specializations.

    gcc/cp/ChangeLog:

            PR c++/94628
            * cp-tree.h (lss_policy::lss_nop): New enumerator.
            * pt.c (local_specialization_stack::local_specialization_stack):
Handle
            an lss_nop policy.
            (local_specialization_stack::~local_specialization_stack):
Likewise.
            (tsubst_pack_expansion): Use a local_specialization_stack instead
of
            manually saving and restoring local_specializations.  Conditionally
            replace local_specializations sooner, before the handling of the
            unsubstituted_packs case.

    gcc/testsuite/ChangeLog:

            PR c++/94628
            * g++.dg/cpp0x/variadic179.C: New test.
            * g++.dg/cpp0x/variadic180.C: New test.

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

end of thread, other threads:[~2020-04-20 22:56 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-15 20:14 [Bug c++/43382] New: Internal error on C++0x code chris at bubblescope dot net
2010-03-15 23:56 ` [Bug c++/43382] ICE " paolo dot carlini at oracle dot com
2010-03-16  8:39 ` chris at bubblescope dot net
2010-03-16 10:28 ` paolo dot carlini at oracle dot com
2010-03-16 11:51 ` rguenth at gcc dot gnu dot org
2010-05-26  4:59 ` [Bug c++/43382] [C++0x] ICE with auto return type and variadic templates jason at gcc dot gnu dot org
2010-05-26 15:00 ` jason at gcc dot gnu dot org
2010-05-26 15:19 ` jason at gcc dot gnu dot org
2010-05-26 17:15 ` jason at gcc dot gnu dot org
     [not found] <bug-43382-4@http.gcc.gnu.org/bugzilla/>
2020-04-20 22:56 ` cvs-commit 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).