public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "steffen.muething at iwr dot uni-heidelberg.de" <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: Mon, 13 Oct 2014 10:02:00 -0000	[thread overview]
Message-ID: <bug-63506-4-26EOyRiQ6K@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-63506-4@http.gcc.gnu.org/bugzilla/>

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


  parent reply	other threads:[~2014-10-13 10:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-10 14:02 [Bug c++/63506] New: " 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 [this message]
2014-12-19 13:51 ` ville.voutilainen at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-63506-4-26EOyRiQ6K@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).