gtest failure error, OS X Mavericks

Help
Sea Woods
2014-02-07
2014-02-12
1 2 > >> (Page 1 of 2)
  • Sea Woods

    Sea Woods - 2014-02-07

    Hello everybody!

    I have successfully complied itpp-4.3.1 in OS X Mavericks. (homebrew cmake fftw)
    However, testing with Google C++ Test Framework sources got the following error:

    $gtests/itpp_gtests

    *** Assertion failed in /Users/sw/Downloads/itpp-4.3.1/itpp/base/vec.cpp on line 252:
    Vec<complex>::set(): Stream operation failed (buffer >> data) (!buffer.fail())
    Abort trap: 6

    also, several warnings during the compiling:

    /Users/sw/Downloads/itpp-4.3.1/itpp/base/bessel/gamma.cpp:204:21: warning:
    comparison of constant -1 with expression of type 'typename
    std::enable_if<std::is_arithmetic<double>::value, bool>::type'
    (aka 'bool') is always false
    [-Wtautological-constant-out-of-range-compare]
    if (std::isinf(x) == -1)
    ~~~~~~~~~~~~~ ^ ~~

    In file included from /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/audiofile.cpp:29:
    In file included from /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/audiofile.h:37:
    /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/audiosample.h:74:15: warning:
    expression result unused [-Wunused-value]
    s < -1.0 ? -1.0 : s > 1.0 ? 1.0 : s;
    ^~~~
    /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/audiofile.cpp:456:16: warning:
    using the result of an assignment as a condition without parentheses
    [-Wparentheses]
    if(data_size = 0xffffffff){
    ~~~~~~~~~~^~~~~~~~~~~~
    /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/audiofile.cpp:456:16: note: place
    parentheses around the assignment to silence this warning
    if(data_size = 0xffffffff){
    ^
    ( )
    /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/audiofile.cpp:456:16: note: use
    '==' to turn this assignment into an equality comparison
    if(data_size = 0xffffffff){
    ^
    ==
    In file included from /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/audiofile.cpp:29:
    In file included from /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/audiofile.h:37:
    /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/audiosample.h:74:15: warning:
    expression result unused [-Wunused-value]
    s < -1.0 ? -1.0 : s > 1.0 ? 1.0 : s;
    ^~~~
    /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/audiosample.h:112:17: note: in
    instantiation of function template specialization
    'itpp::limit_audio_sample<short, 32767="">' requested here
    int16_t l = limit_audio_sample<int16_t, SHRT_MAX="">(s);
    ^
    /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/audiosample.h:74:15: warning:
    expression result unused [-Wunused-value]
    s < -1.0 ? -1.0 : s > 1.0 ? 1.0 : s;
    ^~~~
    /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/audiosample.h:132:12: note: in
    instantiation of function template specialization
    'itpp::limit_audio_sample<signed char,="" '\\x7F'="">' requested here
    return limit_audio_sample<enc_sample_type, SCHAR_MAX="">(s);
    ^
    /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/audiosample.h:74:15: warning:
    expression result unused [-Wunused-value]
    s < -1.0 ? -1.0 : s > 1.0 ? 1.0 : s;
    ^~~~
    /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/audiosample.h:218:22: note: in
    instantiation of function template specialization
    'itpp::limit_audio_sample<int, 8388607="">' requested here
    return Sample_24(limit_audio_sample<int32_t, Sample_24::max_abs_value="">(s));
    ^
    /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/audiosample.h:74:15: warning:
    expression result unused [-Wunused-value]
    s < -1.0 ? -1.0 : s > 1.0 ? 1.0 : s;
    ^~~~
    /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/audiosample.h:238:12: note: in
    instantiation of function template specialization
    'itpp::limit_audio_sample<int, 2147483647="">' requested here
    return limit_audio_sample<enc_sample_type, INT_MAX="">(s);
    ^
    /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/audiofile.cpp:456:16: warning:
    using the result of an assignment as a condition without parentheses
    [-Wparentheses]
    if(data_size = 0xffffffff){
    ~~~~~~~~~~^~~~~~~~~~~~
    /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/audiofile.cpp:551:8: note: in
    instantiation of function template specialization
    'itpp::read_header<itpp::bifstream>' requested here
    if (!read_header(_str,_description, audio_offset,_num_samples)) {
    ^
    /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/audiofile.cpp:456:16: note: place
    parentheses around the assignment to silence this warning
    if(data_size = 0xffffffff){
    ^
    ( )
    /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/audiofile.cpp:456:16: note: use
    '==' to turn this assignment into an equality comparison
    if(data_size = 0xffffffff){
    ^
    ==
    /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/audiofile.cpp:456:16: warning:
    using the result of an assignment as a condition without parentheses
    [-Wparentheses]
    if(data_size = 0xffffffff){
    ~~~~~~~~~~^~~~~~~~~~~~
    /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/audiofile.cpp:683:8: note: in
    instantiation of function template specialization
    'itpp::read_header<itpp::bfstream>' requested here
    if (!read_header(_str,_description, audio_offset,_num_samples)) {
    ^
    /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/audiofile.cpp:456:16: note: place
    parentheses around the assignment to silence this warning
    if(data_size = 0xffffffff){
    ^
    ( )
    /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/audiofile.cpp:456:16: note: use
    '==' to turn this assignment into an equality comparison
    if(data_size = 0xffffffff){
    ^
    ==

    /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/pnm.cpp:453:27: warning: adding
    'char' to a string does not append to the string [-Wstring-plus-int]
    err_msg += pnm_type + " instead of P" + pnm_type_required;
    ~~~~~~~~~^~~~~~~~~~~~~~~~~
    /Users/sw/Downloads/itpp-4.3.1/itpp/srccode/pnm.cpp:453:27: note: use array
    indexing to silence this warning

    Any suggestions? Thanks!

     
  • andy_panov

    andy_panov - 2014-02-07

    please replace assignment with '==' in line 456 of itpp-4.3.1/itpp/srccode/audiofile.cpp
    and add 's =' in the beginning of line 238 in /itpp/srccode/audiosample.h to get rid of some warnings.

    I'll commit a patch asap.

    Andy.

     
  • andy_panov

    andy_panov - 2014-02-07

    Hi,

    Bug request based on your compiler warnings is filed (see here)

    PS still have no idea why string parser fails in vector constructor. It could be a cr-lf issue in itpp sources.
    Please replace line 252 assertion in vec.cpp with
    it_assert(!buffer.fail(), str);
    and post results here.

    Andy.

     
  • Sea Woods

    Sea Woods - 2014-02-08

    Hi Andy

    Thanks a lot! The patch got rid of all warnings.
    Replacing line 252 assertion in vec.cpp got

    $gtests/itpp_gtests
    *** Assertion failed in /Users/sw/Downloads/itpp-4.3.1/itpp/base/vec.cpp on line 251:
    (0,2) (1.5,7.2) (!buffer.fail())
    Abort trap: 6

     
  • andy_panov

    andy_panov - 2014-02-08

    The string passed to vector constructor is correct. It looks like a locale issue (ITPP code will fail if you use comma as decimal point sign). Try export LANG=C before running the program.

    Also, you can run a simple test to detect your default locale settings:

    #include <iostream>
    #include <string>
    #include <sstream>
    
    using namespace std;
    
    int main() {
        string test = "3.14";
        istringstream ss(test);
        double test_val = 0.0;
        ss >> test_val;
        cout << test_val << endl;
        return 0;
    }
    
     
  • Sea Woods

    Sea Woods - 2014-02-08

    Hi Andy

    "export LANG=C" didn't work, I got the same error message.
    The result of the test program is "3.14", not "3,14".

    Thanks

     
  • andy_panov

    andy_panov - 2014-02-08

    Hi,

    Sorry for misleading suggestion. I do not have OS X, so I can only guess the failure reason, since all the tests run smoothly on Linux and Windows.

    Based on the source code investigation, either tokenizer or complex number extraction operator is broken on Mac OS X.

    Could you please show me the failed token? You just need to replace line 252 with
    it_assert(!buffer.fail(), tokens[i]);
    in order to do this.

    Hope it would help to narrow down the search.

    Andy.

     
  • Sea Woods

    Sea Woods - 2014-02-08

    Andy, thanks! The result is

    *** Assertion failed in /Users/sw/Downloads/itpp-4.3.1/itpp/base/vec.cpp on line 251:
    0+2i (!buffer.fail())
    Abort trap: 6

     
  • andy_panov

    andy_panov - 2014-02-08

    Please try following on your machine:

    #include <iostream>
    #include <string>
    #include <sstream>
    
    using namespace std;
    
    int main() {
        string test = "+2";
        istringstream ss(test);
        double test_val = 0.0;
        ss >> test_val;
        cout << test_val << endl;
        return 0;
    }
    

    The expected output is 2.

     
  • Sea Woods

    Sea Woods - 2014-02-09

    Yes, the output is 2.

     
  • andy_panov

    andy_panov - 2014-02-09

    Hi,

    This code reproduces the complex numbers extraction inside library. Could you please verify it does not fail on your system?

    #include <iostream>
    #include <string>
    #include <sstream>
    #include <complex>
    
    namespace std{
    //! Input stream operator for complex numbers (taken from itpp/base/math/misc.h)
    template <class T>
    std::istream& operator>>(std::istream &is, std::complex<T> &x)
    {
      T re, im;
      char c;
      is >> c;
      if (c == '(') {
        is >> re >> c;
        if (c == ',') {
          is >> im >> c;
          if (c == ')') {
            x = complex<T>(re, im);
          }
          else {
            is.setstate(ios_base::failbit);
          }
        }
        else if (c == ')') {
          x = complex<T>(re, T(0));
        }
        else {
          is.setstate(ios_base::failbit);
        }
      }
      else {
        is.putback(c);
        is >> re;
        if (!is.eof() && ((c = static_cast<char>(is.peek())) == '+' || c == '-')) {
          is >> im >> c;
          if (c == 'i') {
            x = complex<T>(re, im);
          }
          else {
            is.setstate(ios_base::failbit);
          }
        }
        else {
          x = complex<T>(re, T(0));
        }
      }
      return is;
    }
    }
    
    using namespace std;
    
    int main() {
        //parsing code from Vec<std::complex<double> >::set(const std::string &str)
        string test = "0+2i";
        istringstream ss(test);
        std::complex<double> test_val = std::complex<double>(0.0,0.0);
        ss >> test_val;
        cout << test_val << endl;
        return 0;
    }
    

    The expected output is
    (0,2)

     
  • Sea Woods

    Sea Woods - 2014-02-09

    Hi Andy

    The output is (0,0), is there something wrong?

    Thanks

     
  • Sea Woods

    Sea Woods - 2014-02-09

    The result of "g++ --version"

    Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr 
    --with-gxx-include-dir=/usr/include/c++/4.2.1
    Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
    Target: x86_64-apple-darwin13.0.2
    Thread model: posix
    
     
  • andy_panov

    andy_panov - 2014-02-10

    Yes, it definitely is.

    Extraction from streams is somewhat broken on MAC OS X.

    I guess, I've managed to find the failure reason - see here for further details.

    Could you please try to rebuild the test example with --stdlib=libstdc++ option as discussed here?

    Andy.

     
  • Sea Woods

    Sea Woods - 2014-02-10

    Andy, yes, you are right!
    compile with --stdlib=libstdc++, the output is (0,2).
    Should I need to rebuild itpp with this option?

    Thanks.

     
  • andy_panov

    andy_panov - 2014-02-10

    Yes, in the meantime, you should add --stdlib=libstdc++ compiler option via cmake in order to rebuild the library and test projects with the same set of options. Unfortunately, I do not know how to do it with cmake :(.

    PS I've already asked Bogdan to help with this.

     
  • Bogdan Cristea

    Bogdan Cristea - 2014-02-10

    changes committed into master branch. Please make sure to use the same option "-stdlib=libstdc++" when you compile your own programs that use IT++

     
  • andy_panov

    andy_panov - 2014-02-10

    Thank you very much, Bogdan!

     
  • Sea Woods

    Sea Woods - 2014-02-10

    Dear Andy and Bogdan

    All tests passed! Thanks a lot!
    BTW, do you know how to add OMP support on OS X?

     
  • andy_panov

    andy_panov - 2014-02-10

    It seems to be a little bit problematic based on this discussion.

    You have to install gcc first.

     
  • Sea Woods

    Sea Woods - 2014-02-11

    CMake detects C/C++ compiler as "cc/c++", which are symbol links to Clang, same as "gcc/g++". To add OpenMP support, I installed gcc-4.8 and compiled again with

    CC=gcc-4.8 CXX=g++-4.8 cmake ..
    make
    

    Then, I got

    .
    .
    [ 99%] Building CXX object itpp/CMakeFiles/itpp.dir/stat/mog_generic.cpp.o
    Linking CXX shared library libitpp.dylib
    duplicate symbol itpp::Vec<std::complex<double> >::Vec(itpp::Vec<std::complex<double> > const&) in:
    CMakeFiles/itpp.dir/base/vec.cpp.o
    CMakeFiles/itpp.dir/signal/freq_filt.cpp.o
    duplicate symbol itpp::Vec<std::complex<double> >::Vec(itpp::Vec<std::complex<double> > const&) in:
    CMakeFiles/itpp.dir/base/vec.cpp.o
    CMakeFiles/itpp.dir/signal/freq_filt.cpp.o
    .
    .
    duplicate symbol itpp::Vec<std::complex<double> >::parse_abc_token(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::complex<double>&, std::complex<double>&, std::complex<double>&) const in:
    CMakeFiles/itpp.dir/base/vec.cpp.o
    CMakeFiles/itpp.dir/signal/freq_filt.cpp.o
    ld: 337 duplicate symbols for architecture x86_64
    collect2: error: ld returned 1 exit status
    make[2]: *** [itpp/libitpp.8.2.1.dylib] Error 1
    make[1]: *** [itpp/CMakeFiles/itpp.dir/all] Error 2
    make: *** [all] Error 2
    

    Any ideas? Thanks.

     
  • Bogdan Cristea

    Bogdan Cristea - 2014-02-11

    It might be related to the fact that using gcc compiler interferes with "-stdlib=libstdc++" option. Please try to start the compilation with
    make VERBOSE=1
    in order to see what command line parameters are passed to the compiler. Also try to remove from CMakeLists.txt file the line that adds the above option

     
  • andy_panov

    andy_panov - 2014-02-11

    Try to comment following lines in /itpp/signal/freq_filt.cpp:

    template  class ITPP_EXPORT Vec<double>;
    template  class ITPP_EXPORT Vec<short>;
    template  class ITPP_EXPORT Vec<int>;
    template  class ITPP_EXPORT Vec<std::complex<double> >;
    

    This should do the trick

     
  • Sea Woods

    Sea Woods - 2014-02-11

    Thanks a lot! Successfully compiled with gcc-4.8 after removing these 4 lines in freq_filt.cpp and that line in CMakeLists.txt, gtest passed too. It looks like gcc-4.8 cannot work with "-stdlib=libstdc++" option. Why these 4 lines should be removed? I compiled them without any error in Windows 7 with MKL and VC 2010.

     
    Last edit: Sea Woods 2014-02-11
  • andy_panov

    andy_panov - 2014-02-11

    There exist subtle differences in msvc & gcc linker operation. MSVC linker just throws away some duplicate definitions, but gcc linker does not. I am not sure which one is more standard compliant in this. I guess I'd missed these lines during refactoring and they should be removed from freq_filt.cpp anyway.

     
1 2 > >> (Page 1 of 2)

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks