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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |ebotcazou at gcc dot gnu.org,
                   |                            |jakub at gcc dot gnu.org
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The bug is in calling
  expr = maybe_constant_value (expr);
That is something that shouldn't be done in code possibly parsed in templates,
unless !processing_template_decl.
A quick fix would be to use
  expr = fold_non_dependent_expr (expr);
and I guess I'll just submit a patch with that.
That is e.g. what we do in OpenMP collapse clause parsing where we really want
a constant already during parsing because how we parse the following code
depends on that.
If that is not the case in #pragma GCC unroll, the normal C++ way would be to
only
check if the result is INTEGER_CST etc. if it is not value dependent expr,
otherwise
pass down a tree and during instantiation instantiate that tree.
That way
template <int N>
void
foo ()
{
#pragma GCC unroll(N)
  for (int i = 0; i != N; ++i)
    ;
}
would be possible.

Reply via email to