public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/63506] New: GCC deduces wrong return type of operator*() inside template functions
@ 2014-10-10 14:02 steffen.muething at iwr dot uni-heidelberg.de
  2014-10-10 14:03 ` [Bug c++/63506] " steffen.muething at iwr dot uni-heidelberg.de
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: steffen.muething at iwr dot uni-heidelberg.de @ 2014-10-10 14:02 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 63506
           Summary: GCC deduces wrong return type of operator*() inside
                    template functions
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: steffen.muething at iwr dot uni-heidelberg.de

Created attachment 33681
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33681&action=edit
Minimal working example based on std::vector<bool>

When trying to convert some iterators in our numerics library DUNE
(dune-project.org) to return temporaries instead of const refs, I stumbled over
the following bug in GCC 4.8.3 and 4.9.1:

Given a class with an operator*() that returns a temporary:

struct iterator
{
  ...

  proxy operator*() const
  {
    return ...;
  }

  proxy get() const
  {
    return ...;
  }

};

the expression 'decltype(*it())' should yield 'proxy', and a variable declared
with 'auto&& x = *it;' should be of type 'proxy&&'. The above is true inside
normal functions:

void bar(iterator it)
{
  typedef decltype(*it()) P; // P == proxy
  auto&& x = *it; // decltype(x) == proxy&&
}

But inside a function template, 'decltype(*it())' becomes 'proxy&', and 'auto&&
x = *it' fails with a compiler error:

template<typename T>
void foo(T t, iterator it)
{
  typedef decltype(*it()) P; // P == proxy&
  auto&& x = *it; // compiler error, see below
}

error: invalid initialization of non-const reference of type 'proxy&' from an
rvalue of type 'proxy'

For some reason, the compiler deduces the wrong type early on and then fails
when it later realizes the correct return type...

This problem can easily be observed with a std::vector<bool>, which returns a
proxy from its iterator. I have attached a minimal working example: The
contained code (which creates a vector and iterates over its contents with a
range-based for loop using auto&&) works in main() and in a normal function
bar(), but it fails to compile in foo(), which is a function template.

GCC 4.6 and 4.7 compile foo() correctly.


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

* [Bug c++/63506] GCC deduces wrong return type of operator*() inside template functions
  2014-10-10 14:02 [Bug c++/63506] New: GCC deduces wrong return type of operator*() inside template functions steffen.muething at iwr dot uni-heidelberg.de
@ 2014-10-10 14:03 ` steffen.muething at iwr dot uni-heidelberg.de
  2014-10-10 14:27 ` steffen.muething at iwr dot uni-heidelberg.de
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: steffen.muething at iwr dot uni-heidelberg.de @ 2014-10-10 14:03 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Steffen Müthing <steffen.muething at iwr dot uni-heidelberg.de> ---
I forgot to mention: This problem is specific to operator*(). If you add an
equivalent normal member function and replace the dereferencing operations with
calls to that function, the problem does not occur.
>From gcc-bugs-return-463761-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Oct 10 14:19:50 2014
Return-Path: <gcc-bugs-return-463761-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 20665 invoked by alias); 10 Oct 2014 14:19:50 -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 20649 invoked by uid 48); 10 Oct 2014 14:19:46 -0000
From: "glisse at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/63506] GCC deduces wrong return type of operator*() inside template functions
Date: Fri, 10 Oct 2014 14:19:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.9.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: glisse at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
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:
Message-ID: <bug-63506-4-Y6x9SFRhep@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-63506-4@http.gcc.gnu.org/bugzilla/>
References: <bug-63506-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-10/txt/msg00782.txt.bz2
Content-length: 187

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

--- Comment #2 from Marc Glisse <glisse at gcc dot gnu.org> ---
Do you mean decltype(*it) (without the extra parentheses) everywhere?


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

* [Bug c++/63506] GCC deduces wrong return type of operator*() inside template functions
  2014-10-10 14:02 [Bug c++/63506] New: GCC deduces wrong return type of operator*() inside template functions steffen.muething at iwr dot uni-heidelberg.de
  2014-10-10 14:03 ` [Bug c++/63506] " steffen.muething at iwr dot uni-heidelberg.de
@ 2014-10-10 14:27 ` steffen.muething at iwr dot uni-heidelberg.de
  2014-10-11  9:58 ` daniel.kruegler at googlemail dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: steffen.muething at iwr dot uni-heidelberg.de @ 2014-10-10 14:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Steffen Müthing <steffen.muething at iwr dot uni-heidelberg.de> ---
Ooops, yes, I did. Actually I meant to write decltype(*iterator()), but
decltype(*it()) doesn't make sense, of course.

And to avoid further confusion: The function get() in the iterator is just
there as an example for a function that avoids the problem (see comment #1).
>From gcc-bugs-return-463766-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Oct 10 14:32:01 2014
Return-Path: <gcc-bugs-return-463766-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 11836 invoked by alias); 10 Oct 2014 14:32:01 -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 11792 invoked by uid 48); 10 Oct 2014 14:31:57 -0000
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/54488] tree loop invariant motion uses an excessive amount of memory
Date: Fri, 10 Oct 2014 14:32:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: tree-optimization
X-Bugzilla-Version: 4.8.0
X-Bugzilla-Keywords: memory-hog
X-Bugzilla-Severity: normal
X-Bugzilla-Who: rguenth at gcc dot gnu.org
X-Bugzilla-Status: UNCONFIRMED
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:
Message-ID: <bug-54488-4-kBzktDGnJ1@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-54488-4@http.gcc.gnu.org/bugzilla/>
References: <bug-54488-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-10/txt/msg00787.txt.bz2
Content-length: 424

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

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
I had patches to implement the suggestion, work on outermost loops separately.
Of course it won't help once you wrap all of them in a single outer loop
(which is why I didn't end up committing this).

Re-measuring state of current trunk would be still nice (I think we must
have improved over the 1GB).


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

* [Bug c++/63506] GCC deduces wrong return type of operator*() inside template functions
  2014-10-10 14:02 [Bug c++/63506] New: GCC deduces wrong return type of operator*() inside template functions steffen.muething at iwr dot uni-heidelberg.de
  2014-10-10 14:03 ` [Bug c++/63506] " steffen.muething at iwr dot uni-heidelberg.de
  2014-10-10 14:27 ` steffen.muething at iwr dot uni-heidelberg.de
@ 2014-10-11  9:58 ` daniel.kruegler at googlemail dot com
  2014-10-13 10:02 ` steffen.muething at iwr dot uni-heidelberg.de
  2014-12-19 13:51 ` ville.voutilainen at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2014-10-11  9:58 UTC (permalink / raw)
  To: gcc-bugs

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

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler@googlemail.
                   |                            |com

--- Comment #4 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
Here is a complete example demonstrating the problem, which is also present in
gcc 5.0.0 20141010 (experimental):

//-------------------------------
struct proxy {};

struct iterator
{
  proxy operator*() { return proxy(); }
};

//#define DEACTIVATE

#ifndef DEACTIVATE
template<typename T = int>
#endif
void foo(iterator it)
{
  auto&& x = *it;
}

int main() 
{
  iterator it;
  foo(it);
}
//-------------------------------
>From gcc-bugs-return-463828-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Oct 11 10:03:42 2014
Return-Path: <gcc-bugs-return-463828-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 31296 invoked by alias); 11 Oct 2014 10:03:42 -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 31270 invoked by uid 48); 11 Oct 2014 10:03:39 -0000
From: "daniel.kruegler at googlemail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/63508] ICE when using bracketed initializer on pointer to member function of a templated class
Date: Sat, 11 Oct 2014 10:03:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.9.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: daniel.kruegler at googlemail dot com
X-Bugzilla-Status: UNCONFIRMED
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-63508-4-rHQd1S9eT3@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-63508-4@http.gcc.gnu.org/bugzilla/>
References: <bug-63508-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-10/txt/msg00849.txt.bz2
Content-length: 2252

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

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler@googlemail.
                   |                            |com

--- Comment #2 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
The ICE also occurs in gcc HEAD 5.0.0 20141010 (experimental):

<quote>
prog.cc: In instantiation of 'c<T>::c() [with T = int]': 
prog.cc:14:23: required from here 
prog.cc:7:22: internal compiler error: Segmentation fault 
  auto x = m{&c::mf}; 
                   ^ 
0x9af2bf crash_signal 
  /home/heads/gcc/gcc-source/gcc/toplev.c:340 
0x55be89 extend_ref_init_temps(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**) 
  /home/heads/gcc/gcc-source/gcc/cp/call.c:9710 
0x55befb extend_ref_init_temps(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**) 
  /home/heads/gcc/gcc-source/gcc/cp/call.c:9732 
0x5aaa15 store_init_value(tree_node*, tree_node*, vec<tree_node*, va_gc,
vl_embed>**, int) 
  /home/heads/gcc/gcc-source/gcc/cp/typeck2.c:792 
0x56f0a5 check_initializer /home/heads/gcc/gcc-source/gcc/cp/decl.c:5892
0x580e9c cp_finish_decl(tree_node*, tree_node*, bool, tree_node*, int)
  /home/heads/gcc/gcc-source/gcc/cp/decl.c:6517 
0x59071e tsubst_expr 
  /home/heads/gcc/gcc-source/gcc/cp/pt.c:13788 
0x58fe05 tsubst_expr 
  /home/heads/gcc/gcc-source/gcc/cp/pt.c:13862 
0x58f6e4 tsubst_expr 
  /home/heads/gcc/gcc-source/gcc/cp/pt.c:13676 
0x58fe05 tsubst_expr 
  /home/heads/gcc/gcc-source/gcc/cp/pt.c:13862 
0x58ea74 instantiate_decl(tree_node*, int, bool) 
  /home/heads/gcc/gcc-source/gcc/cp/pt.c:20241 
0x5a813b instantiate_pending_templates(int) 
  /home/heads/gcc/gcc-source/gcc/cp/pt.c:20357 
0x5c14d8 cp_write_global_declarations() 
  /home/heads/gcc/gcc-source/gcc/cp/decl2.c:4367 

Please submit a full bug report, with preprocessed source if appropriate.
Please include the complete backtrace with any bug report. See
<http://gcc.gnu.org/bugs.html> for instructions.
</quote>
>From gcc-bugs-return-463829-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Sat Oct 11 11:21:02 2014
Return-Path: <gcc-bugs-return-463829-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 6392 invoked by alias); 11 Oct 2014 11:21:01 -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 6281 invoked by uid 48); 11 Oct 2014 11:20:58 -0000
From: "manu at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug other/33702] [meta-bug] GCC 4.4 pending patches
Date: Sat, 11 Oct 2014 11:21:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: other
X-Bugzilla-Version: 4.3.0
X-Bugzilla-Keywords: meta-bug
X-Bugzilla-Severity: normal
X-Bugzilla-Who: manu at gcc dot gnu.org
X-Bugzilla-Status: RESOLVED
X-Bugzilla-Priority: P4
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 4.4.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields: bug_status resolution
Message-ID: <bug-33702-4-rXHqpvdpa2@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-33702-4@http.gcc.gnu.org/bugzilla/>
References: <bug-33702-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-10/txt/msg00850.txt.bz2
Content-length: 473

https://gcc.gnu.org/bugzilla/show_bug.cgi?id3702
Bug 33702 depends on bug 17843, which changed state.

Bug 17843 Summary: Warning not given for unreachable code in a switch
https://gcc.gnu.org/bugzilla/show_bug.cgi?id\x17843

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


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

* [Bug c++/63506] GCC deduces wrong return type of operator*() inside template functions
  2014-10-10 14:02 [Bug c++/63506] New: GCC deduces wrong return type of operator*() inside template functions steffen.muething at iwr dot uni-heidelberg.de
                   ` (2 preceding siblings ...)
  2014-10-11  9:58 ` daniel.kruegler at googlemail dot com
@ 2014-10-13 10:02 ` steffen.muething at iwr dot uni-heidelberg.de
  2014-12-19 13:51 ` ville.voutilainen at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: steffen.muething at iwr dot uni-heidelberg.de @ 2014-10-13 10:02 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 6400 bytes --]

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

--- Comment #5 from Steffen Müthing <steffen.muething at iwr dot uni-heidelberg.de> ---
The exact same problem is present on operator[] :

//-------------------------------
struct proxy {};

struct iterator
{
  proxy operator*() { return proxy(); }

  proxy operator[](int i) { return proxy(); }
};

//#define DEACTIVATE

#ifndef DEACTIVATE
template<typename T = int>
#endif
void foo(iterator it)
{
  auto&& x = *it;
  auto&& y = it[1];
}

int main()
{
  iterator it;
  foo(it);
}
//-------------------------------
>From gcc-bugs-return-463910-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Oct 13 10:20:49 2014
Return-Path: <gcc-bugs-return-463910-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 6394 invoked by alias); 13 Oct 2014 10:20:48 -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 6377 invoked by uid 48); 13 Oct 2014 10:20:45 -0000
From: "lucdanton at free dot fr" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/63522] New: [4.8/4.9/5.0] ICE: unexpected expression 'ElementIndices' of kind template_parm_index
Date: Mon, 13 Oct 2014 10:20:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: new
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: lucdanton at free dot fr
X-Bugzilla-Status: UNCONFIRMED
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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter attachments.created
Message-ID: <bug-63522-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-10/txt/msg00931.txt.bz2
Content-length: 3917

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

            Bug ID: 63522
           Summary: [4.8/4.9/5.0] ICE: unexpected expression
                    'ElementIndices' of kind template_parm_index
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: lucdanton at free dot fr

Created attachment 33696
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id3696&actioníit
Minimal testcase

Attempting to compile the minimal testcase produces "internal compiler error:
unexpected expression 'ElementIndices' of kind template_parm_index". I have
tried the following versions:

$ g++-trunk --version
g++-trunk (GCC) 5.0.0 20141009 (experimental)

$ g++ --version
g++ (Ubuntu 4.8.2-19ubuntu1) 4.8.2

$ g++-4.9
g++-4.9 (GCC) 4.9.0

Program fragment:
--------------------

template <typename...> struct tuple;
template <typename...> void slice();
template <int Index, typename...> using slice_result = decltype(slice<Index>);
template <typename Tuple, typename... Tuples, int... ElementIndices,
          typename               typename tuple<slice_result<ElementIndices, Tuples...>,
                             slice_result<ElementIndices, Tuples...>...>::type>
void zip_with(Tuple...);
decltype(zip_with(0))

----------------------------------------

Here is the full invocation and error using the snapshot of trunk:

$ g++-trunk -std=c++11 main.cpp
main.cpp: In substitution of 'template<int Index, class ...> using slice_result
= decltype (slice<Index>) [with int Index = ElementIndices;
<template-parameter-1-2> = {}]':
main.cpp:5:11:   required by substitution of 'template<class Tuple, class ...
Tuples, int ...ElementIndices, class> void zip_with(Tuple, ...) [with Tuple int; Tuples = {}; int ...ElementIndices = {}; <template-parameter-1-4> <missing>]'
main.cpp:9:20:   required from here
main.cpp:5:11: internal compiler error: unexpected expression 'ElementIndices'
of kind template_parm_index
           typename            ^
0x6755a7 cxx_eval_constant_expression
    ../../gcc/gcc/cp/semantics.c:10050
0x676de6 cxx_eval_outermost_constant_expr
    ../../gcc/gcc/cp/semantics.c:10070
0x5dd190 convert_nontype_argument
    ../../gcc/gcc/cp/pt.c:5759
0x5dd190 convert_template_argument
    ../../gcc/gcc/cp/pt.c:6657
0x5deb5c coerce_template_parms
    ../../gcc/gcc/cp/pt.c:7081
0x5daa28 coerce_innermost_template_parms
    ../../gcc/gcc/cp/pt.c:7165
0x5daa28 instantiate_alias_template
    ../../gcc/gcc/cp/pt.c:15909
0x5daa28 tsubst(tree_node*, tree_node*, int, tree_node*)
    ../../gcc/gcc/cp/pt.c:11723
0x5de392 tsubst_template_args
    ../../gcc/gcc/cp/pt.c:10123
0x5de58f tsubst_template_args
    ../../gcc/gcc/cp/pt.c:10105
0x5e09d0 tsubst_aggr_type
    ../../gcc/gcc/cp/pt.c:10320
0x5da0cf tsubst(tree_node*, tree_node*, int, tree_node*)
    ../../gcc/gcc/cp/pt.c:12299
0x5e4125 type_unification_real
    ../../gcc/gcc/cp/pt.c:16841
0x5e741f fn_type_unification(tree_node*, tree_node*, tree_node*, tree_node*
const*, unsigned int, tree_node*, unification_kind_t, int, bool, bool)
    ../../gcc/gcc/cp/pt.c:16177
0x5a5ca8 add_template_candidate_real
    ../../gcc/gcc/cp/call.c:3025
0x5a6371 add_template_candidate
    ../../gcc/gcc/cp/call.c:3122
0x5a6371 add_candidates
    ../../gcc/gcc/cp/call.c:5253
0x5a797d perform_overload_resolution
    ../../gcc/gcc/cp/call.c:3971
0x5a93ea build_new_function_call(tree_node*, vec<tree_node*, va_gc,
vl_embed>**, bool, int)
    ../../gcc/gcc/cp/call.c:4048
0x66ce39 finish_call_expr(tree_node*, vec<tree_node*, va_gc, vl_embed>**, bool,
bool, int)
    ../../gcc/gcc/cp/semantics.c:2368
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.


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

* [Bug c++/63506] GCC deduces wrong return type of operator*() inside template functions
  2014-10-10 14:02 [Bug c++/63506] New: GCC deduces wrong return type of operator*() inside template functions steffen.muething at iwr dot uni-heidelberg.de
                   ` (3 preceding siblings ...)
  2014-10-13 10:02 ` steffen.muething at iwr dot uni-heidelberg.de
@ 2014-12-19 13:51 ` ville.voutilainen at gmail dot com
  4 siblings, 0 replies; 6+ messages in thread
From: ville.voutilainen at gmail dot com @ 2014-12-19 13:51 UTC (permalink / raw)
  To: gcc-bugs

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

Ville Voutilainen <ville.voutilainen at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-12-19
                 CC|                            |ville.voutilainen at gmail dot com
     Ever confirmed|0                           |1
      Known to fail|                            |5.0

--- Comment #6 from Ville Voutilainen <ville.voutilainen at gmail dot com> ---
Clang accepts the code with or without DEACTIVATE defined.


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

end of thread, other threads:[~2014-12-19 13:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-10-10 14:02 [Bug c++/63506] New: GCC deduces wrong return type of operator*() inside template functions steffen.muething at iwr dot uni-heidelberg.de
2014-10-10 14:03 ` [Bug c++/63506] " steffen.muething at iwr dot uni-heidelberg.de
2014-10-10 14:27 ` steffen.muething at iwr dot uni-heidelberg.de
2014-10-11  9:58 ` daniel.kruegler at googlemail dot com
2014-10-13 10:02 ` steffen.muething at iwr dot uni-heidelberg.de
2014-12-19 13:51 ` ville.voutilainen at gmail dot com

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).