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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org,
                   |                            |mpolacek at gcc dot gnu.org

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
on #c2 I can indeed reproduce, to reproduce in debugger one needs
set disable-randomization off
to reproduce the sometimes ICE sometimes error.
ICE is on
1049                /* All consteval functions should have been processed by
now.  */
1050                gcc_checking_assert (!immediate_invocation_p (decl));
Depending on the address space randomization, the order of
1814      for (auto e : *deferred_escalating_exprs)
1815        if (TREE_CODE (e) == FUNCTION_DECL && !DECL_ESCALATION_CHECKED_P
(e))
1816          cp_fold_immediate (&DECL_SAVED_TREE (e), mce_false, e);
can change, if the order is
_ZN1VC4IiEET_ _ZN1VC2IiEET_ _Z1fv
then there is
pr127537.C: In function ‘void f()’:
pr127537.C:11:15: error: call to consteval function ‘V(1)’ is not a constant
expression
   11 | void f() { V{1}; }
      |               ^
pr127537.C:11:15: error: immediate evaluation returns address of immediate
function ‘constexpr void g() [with T = Y]’
pr127537.C:11:15: note: ‘constexpr V::V(auto:1) [with auto:1 = int]’ was
promoted to an immediate function
while if the order is
_Z1fv _ZN1VC4IiEET_ _ZN1VC2IiEET_
or
_ZN1VC2IiEET_ _Z1fv _ZN1VC4IiEET_
then it ICEs.  Seems in all cases cp_fold_immediate is called on _ZN1VC4IiEET_
and on _Z1fv and not on _ZN1VC2IiEET_, so it is all about which of those 2 is
run first.
So, one question is, should we try harder to always walk the deferred
escalating exprs in some order?  I think the way it is written it uses just
pointer hashing and so is dependent on the VA randomization.  We store there
not just FUNCTION_DECLs (for which we could e.g. use DECL_UIDs), but also
ADDR_EXPRa, so we'd need to do some better ordering.
And, if we promote something to immediate function or whatever
cp_fold_immediately exactly does, don't we have to walk all the expressions
again, until nothing is promoted (or walk at least once)?

Reply via email to