0

I'm trying to open a file with the following piece of code (here I just want to dump all the file to cout):

std::string get_smiles(const std::string* filename, const std::string* directory)
{
    std::ifstream file;
    file.open((*directory + *filename));
    if (file.is_open())
    {
        BOOST_LOG_TRIVIAL(info) << "File is open";
        std::cout << file.rdbuf();
    }
    else BOOST_LOG_TRIVIAL(error) << "Unable to open file";

However, when I run it, I get following message in the log

[2022-04-03 21:01:38.496191] [0x00000001138bee00] [info]    File is open

Process finished with exit code 132 (interrupted by signal 4: SIGILL)

I'm building this using CMake on OSX.

What can I do to resolve this issue?

  • You haven't provided even the full function. What happens after the if...else block? Any way maybe [this](https://stackoverflow.com/a/56993372/1559401) will help. Check all of your `return` statements incl. your `main()`. – rbaleksandar Apr 03 '22 at 19:17
  • Make sure that all functions with non-void return type have a return statement. , https://stackoverflow.com/questions/7901867/what-causes-signal-sigill – H.M Apr 03 '22 at 19:19
  • The problem actually was caused by the missing `return` statement – roma ichenko Apr 03 '22 at 19:26
  • OK, turn up your compiler warnings! – Paul Sanders Apr 03 '22 at 21:41

0 Answers0