public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/56874] New: Argument deduction failure with lambda and default template argument
@ 2013-04-08 12:01 redi at gcc dot gnu.org
  2013-04-08 12:21 ` [Bug c++/56874] " redi at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2013-04-08 12:01 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 56874
           Summary: Argument deduction failure with lambda and default
                    template argument
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: redi@gcc.gnu.org
                CC: jason@gcc.gnu.org


I believe the following code, based on the std::function implementation in
libstdc++, should compile:

template<typename T>
T declval();

template<typename T>
struct function
{
  template<typename F, typename = decltype(declval<F&>() ())>
    function(F)
    { }
};

struct V {
  typedef int value_type;
};

template <typename C>
void map(C&, function<typename C::value_type>)
{
}

int main()
{
  V v;
  map(v, []() { });
}


f.cc: In function 'int main()':
f.cc:24:18: error: no matching function for call to 'map(V&,
main()::__lambda0)'
   map(v, []() { });
                  ^
f.cc:24:18: note: candidate is:
f.cc:17:6: note: template<class C> void map(C&, function<typename
C::value_type>)
 void map(C&, function<typename C::value_type>)
      ^
f.cc:17:6: note:   template argument deduction/substitution failed:
f.cc:24:18: note:   'main()::__lambda0' is not derived from 'function<typename
C::value_type>'
   map(v, []() { });
                  ^

This modified version compiles OK, but whether we say function<int> or
function<typename C::value_type> should not affect deduction of F from the
lambda:

template<typename T>
T declval();

template<typename T>
struct function
{
  template<typename F, typename = decltype(declval<F&>() ())>
    function(F)
    { }
};

struct V {
  typedef int value_type;
};

template <typename C>
void map(C&, function<int>)
{
}

int main()
{
  V v;
  map(v, []() { });
}


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

* [Bug c++/56874] Argument deduction failure with lambda and default template argument
  2013-04-08 12:01 [Bug c++/56874] New: Argument deduction failure with lambda and default template argument redi at gcc dot gnu.org
@ 2013-04-08 12:21 ` redi at gcc dot gnu.org
  2013-04-08 13:01 ` [Bug c++/56874] Argument deduction failure due to non-deduced context redi at gcc dot gnu.org
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2013-04-08 12:21 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-04-08 12:21:29 UTC ---
Possibly a dup of PR 52072 (and PR 53446)


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

* [Bug c++/56874] Argument deduction failure due to non-deduced context
  2013-04-08 12:01 [Bug c++/56874] New: Argument deduction failure with lambda and default template argument redi at gcc dot gnu.org
  2013-04-08 12:21 ` [Bug c++/56874] " redi at gcc dot gnu.org
@ 2013-04-08 13:01 ` redi at gcc dot gnu.org
  2013-04-08 14:56 ` daniel.kruegler at googlemail dot com
  2013-04-08 17:22 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2013-04-08 13:01 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Argument deduction failure  |Argument deduction failure
                   |with lambda and default     |due to non-deduced context
                   |template argument           |

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-04-08 13:01:44 UTC ---
Reduced to remove the lambda and default template argument:

template<typename T>
struct function
{
    function(int)
    { }
};

struct V {
  typedef int value_type;
};

template <typename C>
void map(C&, function<typename C::value_type>)
{
}

int main()
{
  V v;
  map(v, 1);
}


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

* [Bug c++/56874] Argument deduction failure due to non-deduced context
  2013-04-08 12:01 [Bug c++/56874] New: Argument deduction failure with lambda and default template argument redi at gcc dot gnu.org
  2013-04-08 12:21 ` [Bug c++/56874] " redi at gcc dot gnu.org
  2013-04-08 13:01 ` [Bug c++/56874] Argument deduction failure due to non-deduced context redi at gcc dot gnu.org
@ 2013-04-08 14:56 ` daniel.kruegler at googlemail dot com
  2013-04-08 17:22 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2013-04-08 14:56 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler at
                   |                            |googlemail dot com

--- Comment #3 from Daniel Krügler <daniel.kruegler at googlemail dot com> 2013-04-08 14:55:54 UTC ---
I agree, it looks like bug 52072 to me.
>From gcc-bugs-return-419496-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Apr 08 15:03:22 2013
Return-Path: <gcc-bugs-return-419496-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 29099 invoked by alias); 8 Apr 2013 15:03:22 -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 29066 invoked by uid 48); 8 Apr 2013 15:03:19 -0000
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/56854] [4.9 Regression] error: non-decl/MEM_REF LHS in clobber statement
Date: Mon, 08 Apr 2013 15:03: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-Keywords:
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: 4.9.0
X-Bugzilla-Changed-Fields:
Message-ID: <bug-56854-4-HzbSn2jifw@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-56854-4@http.gcc.gnu.org/bugzilla/>
References: <bug-56854-4@http.gcc.gnu.org/bugzilla/>
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
Content-Type: text/plain; charset="UTF-8"
MIME-Version: 1.0
X-SW-Source: 2013-04/txt/msg00641.txt.bz2
Content-length: 1052


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

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> 2013-04-08 15:03:19 UTC ---
(In reply to comment #3)
> So like this?
>
> Reducing testcase now...
>
> --- tree-ssa-forwprop.c.jj12013-02-25 23:51:21.000000000 +0100
> +++ tree-ssa-forwprop.c2013-04-08 16:12:37.908611768 +0200
> @@ -826,7 +826,11 @@ forward_propagate_addr_expr_1 (tree name
>         && integer_zerop (TREE_OPERAND (lhs, 1))
>         && useless_type_conversion_p
>              (TREE_TYPE (TREE_OPERAND (def_rhs, 0)),
> -             TREE_TYPE (gimple_assign_rhs1 (use_stmt))))
> +             TREE_TYPE (gimple_assign_rhs1 (use_stmt)))
> +       /* Don't forward anything into clobber stmts if it would result
> +          in the lhs no longer being a MEM_REF.  */
> +       && (!gimple_clobber_p (use_stmt)
> +           || TREE_CODE (TREE_OPERAND (def_rhs, 0)) == MEM_REF))
>  {
>    tree *def_rhs_basep = &TREE_OPERAND (def_rhs, 0);
>    tree new_offset, new_base, saved, new_lhs;

Yes.


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

* [Bug c++/56874] Argument deduction failure due to non-deduced context
  2013-04-08 12:01 [Bug c++/56874] New: Argument deduction failure with lambda and default template argument redi at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2013-04-08 14:56 ` daniel.kruegler at googlemail dot com
@ 2013-04-08 17:22 ` redi at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: redi at gcc dot gnu.org @ 2013-04-08 17:22 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |DUPLICATE

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> 2013-04-08 17:22:29 UTC ---
Yes, I thought it was different but after reducing it I'm sure it's the same.

*** This bug has been marked as a duplicate of bug 52072 ***


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

end of thread, other threads:[~2013-04-08 17:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-08 12:01 [Bug c++/56874] New: Argument deduction failure with lambda and default template argument redi at gcc dot gnu.org
2013-04-08 12:21 ` [Bug c++/56874] " redi at gcc dot gnu.org
2013-04-08 13:01 ` [Bug c++/56874] Argument deduction failure due to non-deduced context redi at gcc dot gnu.org
2013-04-08 14:56 ` daniel.kruegler at googlemail dot com
2013-04-08 17:22 ` redi 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).