public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/63925] New: ICE with C++14 constexpr when trying to constexprify std::min
@ 2014-11-18  5:04 ville.voutilainen at gmail dot com
  2014-11-18 19:10 ` [Bug c++/63925] " jason at gcc dot gnu.org
  2014-11-18 20:08 ` jason at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: ville.voutilainen at gmail dot com @ 2014-11-18  5:04 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 63925
           Summary: ICE with C++14 constexpr when trying to constexprify
                    std::min
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ville.voutilainen at gmail dot com
                CC: jason at redhat dot com

Test snippet:

#include <initializer_list>

struct _Iter_less_iter
{
  template<typename _Iterator1, typename _Iterator2>
  constexpr bool
  operator()(_Iterator1 __it1, _Iterator2 __it2) const
  { return *__it1 < *__it2; }
};

inline constexpr _Iter_less_iter
__iter_less_iter()
{ return _Iter_less_iter(); }

template<typename _ForwardIterator, typename _Compare>
constexpr _ForwardIterator
__min_element(_ForwardIterator __first, _ForwardIterator __last,
          _Compare __comp)
{
  if (__first == __last)
    return __first;
  _ForwardIterator __result = __first;
  while (++__first != __last)
    if (__comp(__first, __result))
      __result = __first;
  return __result;
}

template<typename _ForwardIterator>
constexpr _ForwardIterator
inline min_element(_ForwardIterator __first, _ForwardIterator __last)
{
  return __min_element(__first, __last,
               __iter_less_iter());
}

template<typename _Tp>
inline constexpr _Tp
min(std::initializer_list<_Tp> __l)
{ return *min_element(__l.begin(), __l.end()); }

int main()
{
  constexpr int foo = min({6, 4});
}

Trace:

[ville@localhost ~]$ g++ --std=c++1y -o constexpr-test2 constexpr-test2.cpp 
constexpr-test2.cpp: In function ‘int main()’:
constexpr-test2.cpp:44:26:   in constexpr expansion of
‘min<int>(std::initializer_list<int>{((const int*)(& ._0)), 2u})’
constexpr-test2.cpp:40:22:   in constexpr expansion of ‘min_element<const
int*>(__l.std::initializer_list<_E>::begin<int>(),
__l.std::initializer_list<_E>::end<int>())’
constexpr-test2.cpp:33:23:   in constexpr expansion of ‘__min_element<const
int*, _Iter_less_iter>(__first, __last, (__iter_less_iter(),
_Iter_less_iter()))’
constexpr-test2.cpp:44:33: internal compiler error: in build2_stat, at
tree.c:4283
   constexpr int foo = min({6, 4});
                                 ^
0xf2b6b6 build2_stat(tree_code, tree_node*, tree_node*, tree_node*)
        ../../gcc/tree.c:4283
0x9eeecf build2_stat_loc
        ../../gcc/tree.h:3560
0x9eeecf fold_build2_stat_loc(unsigned int, tree_code, tree_node*, tree_node*,
tree_node*)
        ../../gcc/fold-const.c:14233
0x7e6e77 cxx_eval_increment_expression
        ../../gcc/cp/constexpr.c:2569
0x7e6e77 cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:3195
0x7e9279 cxx_eval_binary_expression
        ../../gcc/cp/constexpr.c:1485
0x7e63dd cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:3064
0x7e6917 cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:2937
0x7e6b5b cxx_eval_conditional_expression
        ../../gcc/cp/constexpr.c:1511
0x7e6b5b cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:3113
0x7eb105 cxx_eval_statement_list
        ../../gcc/cp/constexpr.c:2686
0x7e64fb cxx_eval_loop_expr
        ../../gcc/cp/constexpr.c:2714
0x7e64fb cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:3248
0x7eb105 cxx_eval_statement_list
        ../../gcc/cp/constexpr.c:2686
0x7e5e7d cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:3182
0x7e65a6 cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:3188
0x7e513c cxx_eval_call_expression
        ../../gcc/cp/constexpr.c:1329
0x7e655d cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:2834
0x7e8b96 cxx_eval_store_expression
        ../../gcc/cp/constexpr.c:2527
0x7e6185 cxx_eval_constant_expression
        ../../gcc/cp/constexpr.c:2913
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.
>From gcc-bugs-return-467107-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Tue Nov 18 05:38:39 2014
Return-Path: <gcc-bugs-return-467107-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 31761 invoked by alias); 18 Nov 2014 05:38:38 -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 31728 invoked by uid 48); 18 Nov 2014 05:38:33 -0000
From: "zhenqiang.chen at arm dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/63917] [5 Regression] r217646 caused many failures
Date: Tue, 18 Nov 2014 05:38:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: rtl-optimization
X-Bugzilla-Version: 5.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: zhenqiang.chen at arm dot com
X-Bugzilla-Status: NEW
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: 5.0
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-63917-4-DzsIoHbtEX@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-63917-4@http.gcc.gnu.org/bugzilla/>
References: <bug-63917-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/msg01579.txt.bz2
Content-length: 287

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

--- Comment #2 from Zhenqiang Chen <zhenqiang.chen at arm dot com> ---
Thanks for the report. I can reproduce the FAIL on IA32. Since the patch does
not impact on -O0, it seams some library functions are wrong. I will
investigate it.


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

* [Bug c++/63925] ICE with C++14 constexpr when trying to constexprify std::min
  2014-11-18  5:04 [Bug c++/63925] New: ICE with C++14 constexpr when trying to constexprify std::min ville.voutilainen at gmail dot com
@ 2014-11-18 19:10 ` jason at gcc dot gnu.org
  2014-11-18 20:08 ` jason at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: jason at gcc dot gnu.org @ 2014-11-18 19:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Jason Merrill <jason at gcc dot gnu.org> ---
Author: jason
Date: Tue Nov 18 19:09:55 2014
New Revision: 217731

URL: https://gcc.gnu.org/viewcvs?rev=217731&root=gcc&view=rev
Log:
    PR c++/63925
    * constexpr.c (cxx_eval_increment_expression): Use POINTER_PLUS_EXPR.

Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/constexpr.c
    trunk/gcc/testsuite/g++.dg/cpp1y/constexpr-incr1.C


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

* [Bug c++/63925] ICE with C++14 constexpr when trying to constexprify std::min
  2014-11-18  5:04 [Bug c++/63925] New: ICE with C++14 constexpr when trying to constexprify std::min ville.voutilainen at gmail dot com
  2014-11-18 19:10 ` [Bug c++/63925] " jason at gcc dot gnu.org
@ 2014-11-18 20:08 ` jason at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: jason at gcc dot gnu.org @ 2014-11-18 20:08 UTC (permalink / raw)
  To: gcc-bugs

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

Jason Merrill <jason at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
                 CC|jason at redhat dot com            |jason at gcc dot gnu.org
         Resolution|---                         |FIXED
           Assignee|unassigned at gcc dot gnu.org      |jason at gcc dot gnu.org
   Target Milestone|---                         |5.0

--- Comment #2 from Jason Merrill <jason at gcc dot gnu.org> ---
Fixed.


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

end of thread, other threads:[~2014-11-18 20:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-18  5:04 [Bug c++/63925] New: ICE with C++14 constexpr when trying to constexprify std::min ville.voutilainen at gmail dot com
2014-11-18 19:10 ` [Bug c++/63925] " jason at gcc dot gnu.org
2014-11-18 20:08 ` jason 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).