Skip to content

Compile warnings on clang >= 6 #721

@jeromekelleher

Description

@jeromekelleher

Because of an upstream bug in clang >= 6, we get warnings with floating point operations like isnan and isfinite,

FAILED: tskit@sha/tskit_trees.c.o                               
clang -Itskit@sha -I. -I.. -Isubprojects/kastore -I../subprojects/kastore -Xclang -fcolor-diagnostics -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c99 -g -fPIC -Wall -Wextra -Werror
 -Wpedantic -W -Wmissing-prototypes -Wstrict-prototypes -Wconversion -Wshadow -Wpointer-arith -Wcast-align -Wcast-qual -Wwrite-strings -Wnested-externs -fshort-enums -fno-common -MD -MQ 'tsk
it@sha/tskit_trees.c.o' -MF 'tskit@sha/tskit_trees.c.o.d' -o 'tskit@sha/tskit_trees.c.o' -c ../tskit/trees.c
../tskit/trees.c:284:28: error: implicit conversion loses floating-point precision: 'const double' to 'float' [-Werror,-Wconversion]
                if (!isnan(mutation_time[mutation])              
                     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~                                                                             
/usr/include/math.h:644:46: note: expanded from macro 'isnan'
#  define isnan(x) __MATH_TG ((x), __isnan, (x))                                                                                
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~^~~                
/usr/include/math.h:559:16: note: expanded from macro '__MATH_TG'
   ? FUNC ## f ARGS                             \               
     ~~~~~~~~~ ^~~~                                              
1 error generated.                                  
[8/52] Compiling C object 'tskit@sha/tskit_tables.c.o'.          
FAILED: tskit@sha/tskit_tables.c.o                                                                                              
clang -Itskit@sha -I. -I.. -Isubprojects/kastore -I../subprojects/kastore -Xclang -fcolor-diagnostics -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -std=c99 -g -fPIC -Wall -Wextra -Werror
 -Wpedantic -W -Wmissing-prototypes -Wstrict-prototypes -Wconversion -Wshadow -Wpointer-arith -Wcast-align -Wcast-qual -Wwrite-strings -Wnested-externs -fshort-enums -fno-common -MD -MQ 'tsk
it@sha/tskit_tables.c.o' -MF 'tskit@sha/tskit_tables.c.o.d' -o 'tskit@sha/tskit_tables.c.o' -c ../tskit/tables.c
../tskit/tables.c:6592:23: error: implicit conversion loses floating-point precision: 'double' to 'float' [-Werror,-Wconversion]
        if (!isfinite(node_time)) {                             
             ~~~~~~~~~^~~~~~~~~~                                 
/usr/include/math.h:629:50: note: expanded from macro 'isfinite'
#  define isfinite(x) __MATH_TG ((x), __finite, (x))             
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~                                                                            
/usr/include/math.h:559:16: note: expanded from macro '__MATH_TG'
   ? FUNC ## f ARGS                             \                                                                               
     ~~~~~~~~~ ^~~~                                             
../tskit/tables.c:6634:24: error: implicit conversion loses floating-point precision: 'double' to 'float' [-Werror,-Wconversion]
        if (!(isfinite(left) && isfinite(right))) {             
              ~~~~~~~~~^~~~~                                     
/usr/include/math.h:629:50: note: expanded from macro 'isfinite'
#  define isfinite(x) __MATH_TG ((x), __finite, (x))             
                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/math.h:559:16: note: expanded from macro '__MATH_TG'
   ? FUNC ## f ARGS                             \                                                                               
     ~~~~~~~~~ ^~~~                               
../tskit/tables.c:6634:42: error: implicit conversion loses floating-point precision: 'double' to 'float' [-Werror,-Wconversion]
        if (!(isfinite(left) && isfinite(right))) {             
                                ~~~~~~~~~^~~~~~     

This is a problem with clang, see e.g. https://bugs.llvm.org/show_bug.cgi?id=35268

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions