Problem p00087 (C++) — buggy submission, verdict: Runtime Error

#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <stack>
#include <string>
using namespace std;
bool str_isdigit(std::string &str) {
  int len = str.length();
  bool dot = false;
  if (len == 0)
    return false;
  else {
    int i = 0;
    if (str[0] == '-' || str[0] == '+') {
      if (1 == len)
        return false; ////
      i++;
    }
    for (; i < len; i++) {
      if (i > 0 && str[i] == '.') {
        if (dot == false)
          dot = true;
        else
          return false;
      }
      if ('9' < str[i] || str[i] < '0')
        return false;
    }
  }
  return true;
}

double gyakupo(double a, double b, char ch) {
  if (ch == '+')
    return a + b;
  if (ch == '-')
    return a - b;
  if (ch == '*')
    return a * b;
  if (ch == '/') {
    if (b == 0.0)
      return -1;
    else
      return a / b;
  }
  return a;
}

int main() {
  stack<double> stk;
  double left, right;
  char ope;
  string str;
  stringstream ss;
  while (true) {
    getline(cin, str);
    if (cin.eof() == true)
      break;
    ss.clear(stringstream::goodbit);
    ss << str;
    while (ss.eof() == false) {
      ss >> str;
      if (str_isdigit(str)) {
        stk.push(atof(str.c_str())); //////
      } else {
        ope = str[0];
        right = stk.top();
        stk.pop();
        left = stk.top();
        stk.pop();
        stk.push(gyakupo(left, right, ope));
        // cout<<"::"<<stk.top()<<endl;////
      }
    }
    cout << fixed << setprecision(6) << stk.top() << endl;
    while (stk.empty() == false)
      stk.pop();
  }
  return 0;
}

Error: -11

Fixed submission:

#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <stack>
#include <string>
using namespace std;
bool str_isdigit(std::string &str) {
  int len = str.length();
  bool dot = false;
  if (len == 0)
    return false;
  else {
    int i = 0;
    if (str[0] == '-' || str[0] == '+') {
      if (1 == len)
        return false;
    }
    for (; i < len; i++) {
      if (i > 0 && str[i] == '.') {
        if (dot == false)
          dot = true;
        else
          return false;
      }
      if ('9' < str[i] || str[i] < '0')
        return false;
    }
  }
  return true;
}

int gyakupo(double a, double b, char ch) {
  if (ch == '+')
    return a + b;
  if (ch == '-')
    return a - b;
  if (ch == '*')
    return a * b;
  if (ch == '/')
    if (b == 0)
      return 0;
    else
      return a / b;
  return a;
}

int main() {
  stack<double> stk;
  double left, right;
  char ope;
  string str;
  stringstream ss;
  while (true) {
    getline(cin, str);
    if (cin.eof() == true)
      break;
    ss.clear(stringstream::goodbit);
    ss << str;
    while (ss.eof() == false) {
      ss >> str;
      if (str_isdigit(str)) {
        stk.push(atof(str.c_str())); //////
      } else {
        ope = str[0];
        right = stk.top();
        stk.pop();
        left = stk.top();
        stk.pop();
        stk.push(gyakupo(left, right, ope));
      }
    }
    cout << fixed << setprecision(6) << stk.top() << endl;
    while (stk.empty() == false)
      stk.pop();
  }
  return 0;
}