[Bug c++/68585] New: [5/6 Regression] c++14 code accepted by 4.9 not accepted by 5 and 6
doko at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Fri Nov 27 14:34:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68585
Bug ID: 68585
Summary: [5/6 Regression] c++14 code accepted by 4.9 not
accepted by 5 and 6
Product: gcc
Version: 5.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: doko at gcc dot gnu.org
Target Milestone: ---
is this code which shouldn't be accepted by 4.9?
$ cat tst.cc
#include <array>
#include <utility>
struct Pos
{
unsigned l,c,a;
//fix g++
// constexpr Pos(unsigned l, unsigned c, unsigned a)
// : l(l), c(c), a(a)
// {}
};
template<class T, T... Ints>
constexpr std::array<Pos, 9*9> make_grid_position(std::integer_sequence<T,
Ints...>)
{
return std::array<Pos, 9*9>{Pos{Ints / 9, Ints % 9, (Ints / 9) / 3 * 3 +
(Ints % 9) / 3}...};
}
constexpr std::array<Pos, 9*9> make_grid_positions()
{
return make_grid_position(std::make_index_sequence<9*9>{});
}
template<class T>
void generate_sudoku(T)
{
constexpr std::array<Pos, 9*9> positions = make_grid_positions(); // fail
}
int main()
{
constexpr std::array<Pos, 9*9> positions = make_grid_positions(); // ok
generate_sudoku(1);
}
$ g++ -std=gnu++14 tst.cc
tst.cc: In instantiation of 'void generate_sudoku(T) [with T = int]':
tst.cc:34:20: required from here
tst.cc:28:66: error: 'std::array<Pos, 81ul>{std::__array_traits<Pos,
81ul>::_Type{Pos{0u, 0u, 0u}, Pos{0u, 1u, 0u}, Pos{0u, 2u, 0u}, Pos{0u, 3u,
1u}, Pos{0u, 4u, 1u}, Pos{0u, 5u, 1u}, Pos{0u, 6u, 2u}, Pos{0u, 7u, 2u},
Pos{0u, 8u, 2u}, Pos{1u, 0u, 0u}, Pos{1u, 1u, 0u}, Pos{1u, 2u, 0u}, Pos{1u, 3u,
1u}, Pos{1u, 4u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, 7u}, Pos{8u, 6u, 8u}, Pos{8u, 7u, 8u},
Pos{8u, 8u, 8u}}}' is not a constant expression
constexpr std::array<Pos, 9*9> positions = make_grid_positions(); // fail
^
More information about the Gcc-bugs
mailing list