Opened 4 months ago

Closed 4 months ago

#22915 closed defect (fixed)

clang 4.0 double promotion warnings in clamp_double_to_int64()

Reported by: nickm Owned by: nickm
Priority: Medium Milestone: Tor: 0.3.2.x-final
Component: Core Tor/Tor Version:
Severity: Normal Keywords: 029-backport, 030-backport, 031-backport, review-group-21
Cc: Actual Points:
Parent ID: Points: .1
Reviewer: ahf Sponsor:

Description

Just upgraded to clang 4.0, and I'm seeing this:

  CC       src/common/util.o
src/common/util.c:5612:13: error: implicit conversion increases floating-point
      precision: 'double' to 'long double' [-Werror,-Wdouble-promotion]
  if (isnan(number)) {
      ~~~~~~^~~~~~~
/usr/include/math.h:385:46: note: expanded from macro 'isnan'
#  define isnan(x) __MATH_TG ((x), __isnan, (x))
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/math.h:320:16: note: expanded from macro '__MATH_TG'
   : FUNC ## l ARGS)
     ~~~~~~~~~ ^~~~
src/common/util.c:5630:16: error: implicit conversion increases floating-point
      precision: 'double' to 'long double' [-Werror,-Wdouble-promotion]
  if (isfinite(number) && exponent <= 63) {
      ~~~~~~~~~^~~~~~~
/usr/include/math.h:370:50: note: expanded from macro 'isfinite'
#  define isfinite(x) __MATH_TG ((x), __finite, (x))
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/math.h:320:16: note: expanded from macro '__MATH_TG'
   : FUNC ## l ARGS)
     ~~~~~~~~~ ^~~~
src/common/util.c:5635:18: error: implicit conversion increases floating-point
      precision: 'double' to 'long double' [-Werror,-Wdouble-promotion]
  return signbit(number) ? INT64_MIN : INT64_MAX;
         ~~~~~~~~^~~~~~~
/usr/include/math.h:361:58: note: expanded from macro 'signbit'
#  define signbit(x) __MATH_TG ((x), __builtin_signbit, (x))
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/math.h:320:16: note: expanded from macro '__MATH_TG'
   : FUNC ## l ARGS)
     ~~~~~~~~~ ^~~~
3 errors generated.

Child Tickets

Change History (9)

comment:1 Changed 4 months ago by nickm

(Ignore deleted comment; it was wrong.)

This is related to, but not the same as, #22081.

comment:2 Changed 4 months ago by nickm

Points: .1
Status: newneeds_review

Please review branch bug22915_029

comment:3 Changed 4 months ago by dgoulet

Component: - Select a componentCore Tor/Tor

The "Tor" component will greatly help :D.

comment:4 in reply to:  1 Changed 4 months ago by cypherpunks

Replying to nickm:

(Ignore deleted comment; it was wrong.)

This is related to, but not the same as, #22081.

#22081 is not related, but #22801 is.

comment:5 Changed 4 months ago by nickm

Keywords: review-group-21 added

comment:6 Changed 4 months ago by nickm

Owner: set to nickm
Status: needs_reviewaccepted

setting owner

comment:7 Changed 4 months ago by nickm

Status: acceptedneeds_review

comment:8 Changed 4 months ago by ahf

Reviewer: ahf
Status: needs_reviewmerge_ready

Minor typo in a comment:

since clang things we're promoting a double to a long double.

should be:

since clang thinks we're promoting a double to a long double.

comment:9 Changed 4 months ago by nickm

Resolution: fixed
Status: merge_readyclosed

Fixed and merged; thanks!

Note: See TracTickets for help on using tickets.