I have two problems. Both can be illustrated by this simple code (compiled with g++ -Wall -O2 -std=c++14):
#include <string>
using namespace std;
const char *printi(const unsigned long &i) {
return to_string(i)).c_str();
}
int main() {
unsigned long i1 = 1; unsigned long i2 = 2;
fprintf(stderr, "%s%s\n", printi(i1), printi(i2));
}
Problem no. 1 - It prints "11", while it should print "12".
Problem no. 2 - Sometimes it doesn't print numbers at all, but some weird characters instead.