Launchpad has imported 9 comments from the remote bug at
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68585.

If you reply to an imported comment from within Launchpad, your comment
will be sent to the remote bug automatically. Read more about
Launchpad's inter-bugtracker facilities at
https://documentation.ubuntu.com/launchpad/user/reference/bugs/multi-project-bugs/about-multi-project-bugs/#bugs-in-external-trackers.

------------------------------------------------------------------------
On 2015-11-27T14:34:06+00:00 Doko-v wrote:

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, 1u}, Pos{1u, 5u, 1u}, Pos{1u, 6u, 2u}, Pos{1u, 7u, 2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7u, 8u}, 
Pos{8u, 8u, 8u}}}' is not a constant expression
   constexpr std::array<Pos, 9*9> positions = make_grid_positions(); // fail
                                                                  ^

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1491643/comments/1

------------------------------------------------------------------------
On 2015-12-01T14:17:38+00:00 Redi wrote:

The code looks valid to me. Preprocessing with 4.9.3 and compiling with
trunk fails, so it's a front-end regression (not something in the
library).

I'll try to reduce it.

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1491643/comments/2

------------------------------------------------------------------------
On 2015-12-01T14:29:31+00:00 Redi wrote:

template<typename T, unsigned N>
  struct array
  {
    T _M_data[N];
  };

template<typename _Tp, _Tp... _Idx>
  struct integer_sequence
  {
  };

struct Pos
{
  unsigned l;
};

template<class T, T... Ints>
constexpr auto make_grid_position(integer_sequence<T, Ints...>)
{
  return array<Pos, sizeof...(Ints)>{{ Pos{Ints}... }};
}

constexpr auto make_grid_positions()
{
  return make_grid_position(integer_sequence<unsigned, 0, 1, 2, 3>{});
}

template<class T>
void generate_sudoku(T)
{
  constexpr auto positions = make_grid_positions(); // fail
}

int main()
{
  constexpr auto positions = make_grid_positions(); // ok
  generate_sudoku(1);
}

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1491643/comments/3

------------------------------------------------------------------------
On 2015-12-01T14:32:02+00:00 Redi wrote:

Or this version is valid C++11 (and accepted by clang and EDG):

template<typename T, unsigned N>
  struct array
  {
    T _M_data[N];
  };

template<typename _Tp, _Tp... _Idx>
  struct integer_sequence
  {
  };

struct Pos
{
  unsigned l;
};

template<class T, T... Ints>
constexpr array<Pos, sizeof...(Ints)> make_grid_position(integer_sequence<T, 
Ints...>)
{
  return {{ Pos{Ints}... }};
}

constexpr array<Pos, 1> make_grid_positions()
{
  return make_grid_position(integer_sequence<unsigned, 0>{});
}

template<class T>
void generate_sudoku(T)
{
  constexpr auto positions = make_grid_positions(); // fail
}

int main()
{
  constexpr auto positions = make_grid_positions(); // ok
  generate_sudoku(1);
}

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1491643/comments/4

------------------------------------------------------------------------
On 2015-12-01T14:54:43+00:00 Jakub-gcc wrote:

#c3 started to be rejected with r216750.

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1491643/comments/5

------------------------------------------------------------------------
On 2015-12-04T10:45:00+00:00 Rguenth wrote:

GCC 5.3 is being released, adjusting target milestone.

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1491643/comments/6

------------------------------------------------------------------------
On 2016-02-18T05:08:35+00:00 Jason-gcc wrote:

Author: jason
Date: Thu Feb 18 05:08:02 2016
New Revision: 233513

URL: https://gcc.gnu.org/viewcvs?rev=233513&root=gcc&view=rev
Log:
        PR c++/68585
        * constexpr.c (cxx_eval_bare_aggregate): Fix 'changed' detection.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist9.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/constexpr.c

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1491643/comments/7

------------------------------------------------------------------------
On 2016-02-18T14:49:54+00:00 Jason-gcc wrote:

Author: jason
Date: Thu Feb 18 14:49:22 2016
New Revision: 233522

URL: https://gcc.gnu.org/viewcvs?rev=233522&root=gcc&view=rev
Log:
        PR c++/68585
        * constexpr.c (cxx_eval_bare_aggregate): Fix 'changed' detection.

Added:
    branches/gcc-5-branch/gcc/testsuite/g++.dg/cpp0x/constexpr-initlist9.C
Modified:
    branches/gcc-5-branch/gcc/cp/ChangeLog
    branches/gcc-5-branch/gcc/cp/constexpr.c

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1491643/comments/8

------------------------------------------------------------------------
On 2016-02-19T19:30:28+00:00 Jason-gcc wrote:

Fixed.

Reply at:
https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1491643/comments/9


** Changed in: gcc
       Status: Unknown => Fix Released

** Changed in: gcc
   Importance: Unknown => Medium

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1491643

Title:
  Construction failure of a POD through a constexpr function if called
  in a template function

To manage notifications about this bug go to:
https://bugs.launchpad.net/gcc/+bug/1491643/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to