Menu

#422 PDL misc. compiler warnings.

normal
closed
nobody
None
5
2016-10-08
2016-06-08
No

This is on Mac OS 10.11 with PDL 2.016 (more -V at end)

8 Compiler warnings from build we ought to cleanup:

—------------------------------------------------------

1)

pdlcore.c:1292:86: warning: format specifies type 'double' but the argument has type 'PDL_Indx' (aka 'long') [-Wformat]
fprintf(stderr,"Warning: pdl_setav_Indx converted undef to (%g) %ld time%s\n",undefval,undef_count,undef_count==1?"":"s");
~~ ^~~~~~~~
%ld
pdlcore.c:1675:87: warning: format specifies type 'double' but the argument has type 'PDL_Short' (aka 'short') [-Wformat]
fprintf(stderr,"Warning: pdl_setav_Short converted undef to (%g) %ld time%s\n",undefval,undef_count,undef_count==1?"":"s");

etc etc etc

—————————————————————————————————

2)

pdlapi.c:500:29: warning: format specifies type 'double' but the argument has type 'PDL_Anyval' [-Wformat]
printf("%s%f",(i?" ":""),pdl_get_offs(it,i));
~~ ^~~~~~~~~~~~~~~~~~
pdlapi.c:1450:9: warning: absolute value function 'abs' given an argument of type 'PDL_Indx' (aka 'long') but has parameter of type 'int' which may cause
truncation of value [-Wabsolute-value]
inc= abs(inc);
^
pdlapi.c:1450:9: note: use function 'labs' instead
inc= abs(inc);

—————————————————————————————————

3) in Bad.xs Math.xs and Ufunc.xs a lot of:

Math.xs:13157:43: warning: 'finite' is deprecated: first deprecated in OS X 10.9 [-Wdeprecated-declarations]
(c_datap)[0] PDL_COMMENT("ACCESS()") = ( finite((a_datap)[0] PDL_COMMENT("ACCESS()") ) && (a_datap)[0] PDL_COMMENT("ACCESS()") != a_badval ) ? (a_dat...
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/math.h:757:12: note: 'finite' has been
explicitly marked deprecated here
extern int finite(double) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_0, __MAC_10_9, __IPHONE_NA, __IPHONE_NA);

etc…

—————————————————————————————————

4) Gaussian.xs and FFT.xs a lot of:

Gaussian.xs:672:18: warning: using integer absolute value function 'abs' when argument is of floating point type [-Wabsolute-value]
if ( abs((xval_datap)[0+(__inc_xval_n*PP_INDTERM(__privtrans->__n_size, n))] PDL_COMMENT("ACCESS()") -xmin) > 0.9abs(xmax-xmin) ) {
^
Gaussian.xs:672:18: note: use function 'fabs' instead
if ( abs((xval_datap)[0+(__inc_xval_n*PP_INDTERM(__privtrans->__n_size, n))] PDL_COMMENT("ACCESS()") -xmin) > 0.9
abs(xmax-xmin) ) {
^~~
fabs

etc.
—————————————————————————————————

5)

resample.c:292:14: warning: implicitly declaring library function 'strcmp' with type 'int (const char , const char )'
} else if (!strcmp(kernel_type, "default")) {
^
resample.c:292:14: note: include the header <string.h> or explicitly provide a declaration for 'strcmp'
1 warning generated.</string.h>

6) ./SlatecProtos.h:1:8: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
extern ssvdc_ ();
~~~~~~ ^
./SlatecProtos.h:2:8: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
extern spoco_ ();
~~~~~~ ^

—————————————————————————————————

7)

INTEG.xs:18122:10: warning: implicit declaration of function 'warn' is invalid in C99 [-Wimplicit-function-declaration]
warn("Bounds checking is disabled for PDL::GSL::INTEG");
—————————————————————————————————

    ^

8) RNG.xs:48112:10: warning: enumeration values 'PDL_IND' and 'PDL_LL' not handled in switch [-Wswitch]
switch(in->datatype) {

[~] % perldl -V
perlDL shell v1.357
PDL comes with ABSOLUTELY NO WARRANTY. For details, see the file
'COPYING' in the PDL distribution. This is free software and you
are welcome to redistribute it under certain conditions, see
the same file for details.

Summary of my PDL configuration

VERSION: PDL v2.016 (supports bad values)

$%PDL::Config = {
'WITH_PROJ' => '0',
'BADVAL_PER_PDL' => '0',
'WITH_IO_BROWSER' => '0',
'WITH_DEVEL_REPL' => '1',
'PROJ_INC' => undef,
'HDF_LIBS' => undef,
'GSL_INC' => undef,
'HIDE_TRYLINK' => '1',
'POSIX_THREADS_LIBS' => undef,
'WITH_MINUIT' => '1',
'USE_POGL' => '0',
'HDF_INC' => undef,
'OPTIMIZE' => undef,
'WITH_GSL' => '1',
'SKIP_KNOWN_PROBLEMS' => '0',
'GSL_LIBS' => undef,
'PDL_BUILD_DIR' => '/Users/karl/Downloads/PDL-2.016',
'HTML_DOCS' => '1',
'FITS_LEGACY' => '1',
'WITH_BADVAL' => '1',
'MINUIT_LIB' => undef,
'PDL_BUILD_VERSION' => '2.016',
'GD_INC' => undef,
'PDL_CONFIG_VERSION' => '0.005',
'WITH_HDF' => '0',
'WITH_3D' => '0',
'PROJ_LIBS' => undef,
'GD_DEFINE' => '',
'GD_LIBS' => undef,
'POGL_VERSION' => '0.6702',
'BADVAL_USENAN' => '0',
'WITH_SLATEC' => '1',
'MALLOCDBG' => {
'libs' => '',
'include' => ''
},
'TEMPDIR' => '/var/folders/zy/5lz5l7_s33dbcn256pfnn1jw0000gq/T',
'POGL_WINDOW_TYPE' => 'glut',
'WITH_GD' => '0',
'POSIX_THREADS_INC' => undef,
'WITH_POSIX_THREADS' => '0',
'PDLDOC_IGNORE_AUTOLOADER' => '0'
};
Summary of my perl5 (revision 5 version 22 subversion 1) configuration:

Platform:
osname=darwin, osvers=14.5.0, archname=darwin-2level
uname='darwin kglazebrook4-mac.local 14.5.0 darwin kernel version 14.5.0: wed jul 29 02:26:53 pdt 2015; root:xnu-2782.40.9~1release_x86_64 x86_64 '
config_args='-de -Dprefix=/Applications/PDL'
hint=recommended, useposix=true, d_sigaction=define
useithreads=undef, usemultiplicity=undef
use64bitint=define, use64bitall=define, uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -I/opt/local/include',
optimize='-O3',
cppflags='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -I/opt/local/include'
ccversion='', gccversion='4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)', gccosandvers=''
intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678, doublekind=3
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=3
ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector-strong -L/usr/local/lib -L/opt/local/lib'
libpth=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/6.1.0/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib /usr/local/lib /opt/local/lib /usr/lib
libs=-lpthread -ldbm -ldl -lm -lutil -lc
perllibs=-lpthread -ldl -lm -lutil -lc
libc=, so=dylib, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -L/opt/local/lib -fstack-protector-strong'

% gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/c++/4.2.1
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.4.0
Thread model: posix

Discussion

  • Karl Glazebrook

    Karl Glazebrook - 2016-06-08

    From Derek Lamb:

    1) was addressed in the deprecate-finite branch that was recently merged into master post-2.016.

    3) is addressed in the types-printconv branch that has not yet been merged—needs some code review to make sure it will pass on 32-bit and 64-bit platforms with different values of ivsize, etc. It hadn't been shaken out enough yet to merge before 2.016. It probably could be generalized and used in other places as well. Or even made a little cleaner: generating some "#define USHORT_FLAG hu" (or whatever) statements in pdl.h instead of the ugly (but working) current implementation.

    clang complains about a lot of things that really aren't problems or that fixing may cause more portability problems for different compilers/architectures. Or that are sort-of-generic code that needs thought into how to deal with all the different datatypes that a chunk of code might actually see. So if you'd like to fix them, go ahead, but proceed slowly, and push to branches, not to master. See the recommended workflow in the DEVELOPMENT file—it's spelled out step-by-step there.


    8, 7, 6, 5, and 4 (for Gaussian) are fixed in the clang_warnings branch.

    I have solutions for 4 (for FFT) and 2 (the abs/labs part), but I'm not sure how portable they are. See below.

    I'll need to think some more about 2 (the Anyval part).

    inc is of type PDL_Indx, on my machine that is long, but it could be longlong (and thus need llabs), so this might just be kicking the can down the road:

    diff --git a/Basic/Core/pdlapi.c b/Basic/Core/pdlapi.c
    index 43d649d..c709b3d 100644
    --- a/Basic/Core/pdlapi.c
    +++ b/Basic/Core/pdlapi.c
    @@ -1447,7 +1447,7 @@ void pdl_make_physvaffine(pdl it)
    /
    inc = the increment at the current stage */
    inc = it->vafftrans->incs[i];
    incsign = (inc >= 0 ? 1:-1);

    • inc= abs(inc);
    • inc= labs(inc);
      newinc = 0;
      / For all dimensions of the current piddle /
      for(j=current->ndims-1; j>=0 && current->dimincs[j] != 0; j--) {

    Similarly here: types L, N, and Q could need abs, labs, or llabs depending on the implementation.

    diff --git a/Lib/FFT/fft.pd b/Lib/FFT/fft.pd
    index 291e055..3bac5a4 100644
    --- a/Lib/FFT/fft.pd
    +++ b/Lib/FFT/fft.pd
    @@ -561,7 +561,10 @@ pp_def('cdiv',
    ai = $ai();
    br = $br();
    bi = $bi();

    • if (fabs(br) > fabs(bi)) {
    • if (types(BU) %{ br > bi %}
    • types(SL) %{ abs(br) > abs(bi) %}
    • types(NQ) %{ labs(br) > labs(bi) %}
    • types(FD) %{ fabs(br) > fabs(bi) %} ) {
      tt = bi/br;
      dn = br + ttbi;
      $cr() = (ar+tt
      ai)/dn;

    cheers,
    Derek

     

    Last edit: Karl Glazebrook 2016-06-08
  • Derek Lamb

    Derek Lamb - 2016-06-09

    With the sum of the commits on the branches

    1. types_printconv
    2. clang_warnings
    3. add_datatype_invalid

    and the changes that Karl kindly pasted in (which I am not totally happy with and so have not committed), we are very very close to having PDL build with no compiler warnings on OS X. I hope that these changes don't increase the amount of warnings on other platforms!

     
  • Derek Lamb

    Derek Lamb - 2016-08-29
    • status: open --> pending-fixed
     
  • Derek Lamb

    Derek Lamb - 2016-08-29

    On my machine, the current master (commit 0cce28) compiles with no errors and no warnings using clang on my Mac. Marking as pending-fixed.

     
  • Chris Marshall

    Chris Marshall - 2016-10-08
    • status: pending-fixed --> closed
     

Log in to post a comment.