This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/64647] New: [5 Regression] [C++14] std::__max_element contains code not allowed in constexpr function
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Sat, 17 Jan 2015 18:01:36 +0000
- Subject: [Bug libstdc++/64647] New: [5 Regression] [C++14] std::__max_element contains code not allowed in constexpr function
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64647
Bug ID: 64647
Summary: [5 Regression] [C++14] std::__max_element contains
code not allowed in constexpr function
Product: gcc
Version: 5.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
CC: ville.voutilainen at gmail dot com
#include <forward_list>
#include <algorithm>
int main()
{
std::forward_list<int> v;
std::max_element(v.begin(), v.end());
}
Compiling with -std=c++14 gives:
In file included from /home/jwakely/gcc/5/include/c++/5.0.0/algorithm:62:0,
from max.cc:2:
/home/jwakely/gcc/5/include/c++/5.0.0/bits/stl_algo.h: In instantiation of
âconstexpr _ForwardIterator std::__max_element(_ForwardIterator,
_ForwardIterator, _Compare) [with _ForwardIterator =
std::_Fwd_list_iterator<int>; _Compare = __gnu_cxx::__ops::_Iter_less_iter]â:
/home/jwakely/gcc/5/include/c++/5.0.0/bits/stl_algo.h:5514:43: required from
âconstexpr _FIter std::max_element(_FIter, _FIter) [with _FIter =
std::_Fwd_list_iterator<int>]â
max.cc:7:38: required from here
/home/jwakely/gcc/5/include/c++/5.0.0/bits/stl_algo.h:5489:35: error: variable
â__resultâ of non-literal type âstd::_Fwd_list_iterator<int>â in âconstexprâ
function
_ForwardIterator __result = __first;
^
In file included from /home/jwakely/gcc/5/include/c++/5.0.0/forward_list:38:0,
from max.cc:1:
/home/jwakely/gcc/5/include/c++/5.0.0/bits/forward_list.h:120:12: note:
âstd::_Fwd_list_iterator<int>â is not literal because:
struct _Fwd_list_iterator
^
/home/jwakely/gcc/5/include/c++/5.0.0/bits/forward_list.h:120:12: note:
âstd::_Fwd_list_iterator<int>â is not an aggregate, does not have a trivial
default constructor, and has no constexpr constructor that is not a copy or
move constructor