Skip to content

[Regression 16 -> 17] Template instantiation ignores FENV_ACCESS being ON for both definition and instantiation #64605

Closed
@hubert-reinterpretcast

Description

@hubert-reinterpretcast

Consider:

#pragma STDC FENV_ACCESS ON
template <typename>
int b() {
  int x;
  if ((float)0xFFFFFFFF != (float)0x100000000) {
    x = 1;
  }
  return x;
}
int f() { return b<void>(); }

Clang 16 generates the floating-point operations (as is appropriate for FENV_ACCESS being ON):

f():                                  # @f()
        mov     eax, 4294967295
        cvtsi2ss        xmm0, rax
        movabs  rax, 4294967296
        cvtsi2ss        xmm1, rax
        ucomiss xmm0, xmm1
        mov     eax, 1
        ret

Clang "17" currently generates no floating-point operations:

f(): # @f()
  ret

Compiler Explorer: https://godbolt.org/z/PcoaaxzKn

Reverting fde5924 restores the previous behaviour.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions