Opened 12 years ago

Closed 12 years ago

#3868 closed Bug (fixed)

util tests fail on Solaris 11 because sqrt(-1) is "-nan"

Reported by: cloyce Owned by: charles
Priority: Normal Milestone: 2.20
Component: libtransmission Version: 2.13
Severity: Minor Keywords: utils, tr_truncd


On Solaris 11 Express (11/10) using the Studio 12.2 compilers, the utils-test fails during testing of tr_truncd().

The problem test is on lines 406-407 of utils-test.c:

    tr_snprintf( buf, sizeof( buf ), "%.2f", tr_truncd( nan, 2 ) );
    check( !strcmp( buf, "nan" ) );

On Solaris 11 (and maybe others; I didn't check)

  printf( "%.2f", sqrt(-1))   =>  "-nan"

That is to say, this isn't a problem with tr_snprintf() or tr_truncd().

I'm not exactly sure what this test is testing for (that tr_truncd() doesn't convert a NaN back to a number?), so I don't know what to suggest for a solution. Making the test pass is pretty easy... just change line 407 to

    check( strstr( buf, "nan" ) );

That should still be safe, as I don't think it should be possible to get any other strings containing "nan" out of a "%.2f" printf().

Sorry, I have no idea how to set the priority and severity. Please adjust accordingly.

Change History (2)

comment:1 Changed 12 years ago by charles

  • Milestone changed from None Set to 2.20
  • Severity changed from Normal to Minor
  • Status changed from new to assigned

comment:2 Changed 12 years ago by charles

  • Resolution set to fixed
  • Status changed from assigned to closed

Thanks for reporting this and for investigating it so in-depth.

Fixed in trunk for r11618

Note: See TracTickets for help on using tickets.