0

I'm learning C++ using the learncpp website, i'm on Windows 64bits and i'm using GCC with C++14.

I tried to implement the example in the std::bitset parts of this chapter : http://www.learncpp.com/cpp-tutorial/3-8a-bit-flags-and-bit-masks/

No error at compile time but when I launch the program I get this error :

https://puu.sh/AupYw/d0c7fa01a8.png

Here is my code :

#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <bitset>

int main()
{

    const int option0 = 0;
    const int option1 = 1;
    const int option2 = 2;
    const int option3 = 3;
    const int option4 = 4;
    const int option5 = 5;
    const int option6 = 6;
    const int option7 = 7;

    std::bitset<8> bits(0x2); // we need 8 bits, start with bit pattern 0000 0010
    bits.set(option4); // set bit 4 to 1 (now we have 0001 0010)

    /*bits.flip(option5);
    bits.reset(option5);

    std::cout << "Bit 4 has value: " << bits.test(option4) << '\n';
    std::cout << "Bit 5 has value: " << bits.test(option5) << '\n';
    std::cout << "All the bits: " << bits << '\n';*/

}

You have to know that if we remove the set function no error is thrown.

I think that there is a problem in the option initialization but can't figure it out :/

Here is a (very inaccurate) translation for the error : "The procedure entry point _ZSt24__throw_out_of_range_fmtPKcz can't be found in the dynamic link library"

Thanks in advance.

Alvin FREY
  • 43
  • 11
  • 1
    The error has nothing to do with the code you posted, it compiles and runs fine https://ideone.com/bb5d3B – Killzone Kid May 28 '18 at 10:00
  • What compiler options are you using? – Paul Floyd May 28 '18 at 10:03
  • The only compiler options I checked is : -std=c++14 – Alvin FREY May 28 '18 at 10:06
  • So it appears that something wants to throw an `std:out_of_range` exception. `c++filt _ZSt24__throw_out_of_range_fmtPKcz` yields `std::__throw_out_of_range_fmt(char const*, ...)`. Please double-check if that's really the exact code that causes that error message to pop up because for me (and for others too, apparently) it doesn't. – cadaniluk May 28 '18 at 10:09
  • Maybe surrounding with `try` and `catch` + debugging helps find the issue (in case of a throw, look at the call stack) – MauriceRandomNumber May 28 '18 at 10:16
  • It seems that I have to put -static-libgcc and -static-libstdc++ options and rebuild the project because this works now :) – Alvin FREY May 28 '18 at 12:38

0 Answers0