Thanks to visit codestin.com
Credit goes to github.com

Skip to content

sprintf_s: FP exception (DIVBYZERO) with _MM_FLUSH_ZERO_ON. #144

@pavelliavonau

Description

@pavelliavonau

With safeclib 3.8.1 I've got an exception with a code that worked before with 3.3.0

#include <fenv.h>
#include <cfenv>
#include <xmmintrin.h>
#include <safe_str_lib.h>
 
int main(void)
{
    const int MAXLINELENGTH1 = 200;
    static char s[MAXLINELENGTH1];
    sprintf_s(s, MAXLINELENGTH1, "  %e", 0.0);       //   <-- Here is fine

    feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
 
    _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); 

    sprintf_s(s, MAXLINELENGTH1, "  %e", 0.0);       //   <-- Exception is here
}

I use RedHat 8 with GCC 11.

Exception occurs here

value /= conv.F;

Looks like a bug

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions