Bug #1485

Some clang compiler warnings

Added by Deil Christoph about 9 years ago. Updated over 8 years ago.

Status:ClosedStart date:06/28/2015
Priority:NormalDue date:
Assigned To:Knödlseder Jürgen% Done:

100%

Category:-
Target version:-
Duration:

Description

I’m getting a few compiler warnings on my Macbook.

This one is actually a bug:

GMath.cpp:423:9: warning: taking the absolute value of unsigned type 'bool' has no effect [-Wabsolute-value]
    if (std::abs(arg > 1.0)) {
        ^
GMath.cpp:423:9: note: remove the call to 'abs' since unsigned values cannot be negative
    if (std::abs(arg > 1.0)) {
        ^~~~~~~~
GMath.cpp:428:14: warning: taking the absolute value of unsigned type 'bool' has no effect [-Wabsolute-value]
    else if (std::abs(arg == 1.0)) {
             ^
GMath.cpp:428:14: note: remove the call to 'abs' since unsigned values cannot be negative
    else if (std::abs(arg == 1.0)) {
             ^~~~~~~~

Fix is here ... please merge these two commits:
https://github.com/gammalib/gammalib/compare/devel...cdeil:fix-clang-compile-warnings

This one is probably platform-dependent ... I don’t know if it can be fixed or silenced:

GVOHub.cpp:320:18: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
    if (m_socket < 0) {
        ~~~~~~~~ ^ ~
GVOHub.cpp:365:17: warning: comparison of unsigned expression < 0 is always false [-Wtautological-compare]
        if (socket < 0) {
            ~~~~~~ ^ ~

This one is in SWIG-generated code, I just thought I’d mention it in case it indicates an issue with the Gammalib Python wrapper:

gammalib/sky_wrap.cpp:4032:9: warning: destination for this 'memset' call is a pointer to dynamic class 'GSkyDir'; vtable pointer
      will be overwritten [-Wdynamic-class-memaccess]
        memset(v_def,0,sizeof(Type));
        ~~~~~~ ^
gammalib/sky_wrap.cpp:4057:62: note: in instantiation of member function 'swig::traits_as<GSkyDir, swig::pointer_category>::as'
      requested here
    return traits_as<Type, typename traits<Type>::category>::as(obj, te);
                                                             ^
gammalib/sky_wrap.cpp:4614:15: note: in instantiation of function template specialization 'swig::as<GSkyDir>' requested here
        return swig::as<T>(item, true);
                     ^
gammalib/sky_wrap.cpp:4849:42: note: in instantiation of member function 'swig::SwigPySequence_Ref<GSkyDir>::operator GSkyDir'
      requested here
      seq->insert(seq->end(),(value_type)(*it));
                                         ^
gammalib/sky_wrap.cpp:4871:6: note: in instantiation of function template specialization
      'swig::assign<swig::SwigPySequence_Cont<GSkyDir>, std::__1::vector<GSkyDir, std::__1::allocator<GSkyDir> > >' requested here
            assign(swigpyseq, pseq);
            ^
gammalib/sky_wrap.cpp:4926:47: note: in instantiation of member function 'swig::traits_asptr_stdseq<std::__1::vector<GSkyDir,
      std::__1::allocator<GSkyDir> >, GSkyDir>::asptr' requested here
        return traits_asptr_stdseq<std::vector<T> >::asptr(obj, vec);
                                                     ^
gammalib/sky_wrap.cpp:3949:32: note: in instantiation of member function 'swig::traits_asptr<std::__1::vector<GSkyDir,
      std::__1::allocator<GSkyDir> > >::asptr' requested here
    return traits_asptr<Type>::asptr(obj, vptr);
                               ^
gammalib/sky_wrap.cpp:17291:18: note: in instantiation of function template specialization 'swig::asptr<std::__1::vector<GSkyDir,
      std::__1::allocator<GSkyDir> > >' requested here
    res4 = swig::asptr(obj3, &ptr);
                 ^
gammalib/sky_wrap.cpp:4032:9: note: explicitly cast the pointer to silence this warning
        memset(v_def,0,sizeof(Type));
               ^
               (void*)


Recurrence

No recurrence.

History

#1 Updated by Deil Christoph about 9 years ago

One more warning in ctools:

ctselect.cpp:287:41: warning: 'tmpnam' is deprecated: This function is provided for compatibility reasons only. Due to security
      concerns inherent in the design of tmpnam(3), it is highly recommended that you use mkstemp(3) instead.
      [-Wdeprecated-declarations]
            std::string filename = std::tmpnam(NULL);
                                        ^
/usr/include/stdio.h:276:7: note: 'tmpnam' has been explicitly marked deprecated here
char    *tmpnam(char *);
         ^

#2 Updated by Knödlseder Jürgen over 8 years ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

I cleaned the code to remove the warning where we have a handle on (does not concern the swig related warnings).

Also available in: Atom PDF