Skip to content

clang/llvm don't support C99 FP rounding mode pragmas (FENV_ACCESS etc) #8472

Open
@llvmbot

Description

@llvmbot
Bugzilla Link 8100
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @andykaylor,@delcypher,@DimitryAndric,@emaste,@ecnelises,@ismail,@kcc,@sunfishcode,@zygoloid,@rnk,@rotateright,@tavianator,@tydeman,@vinc17fr,@vadz,@yabinc,@yuanfang-chen,@zamazan4ik

Extended Description

Hello,

consider this code:

#include <fenv.h>
#include <assert.h>

int main(){
double a=1.1;
double b=10.1;
fesetround(FE_UPWARD);
assert(-((-a)b)!=ab);
}

Excessive optimization will remove the double negation. gcc has option -frounding-math to help with this. Intel's -fp-model strict is not quite as good (it fails for this example) but it helps (for instance it lets the code work if I write 1.1 and 10.1 instead of a and b in the assertion). With llvm-gcc or clang, this always fails at -O1.

A similar option for llvm would be very welcome, there are applications where rounding in the appropriate direction is crucial (precision and speed come far behind).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang:frontendLanguage frontend issues, e.g. anything involving "Sema"floating-pointFloating-point math

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions