[llvm-commits] [polly] r138203 - /polly/trunk/lib/Support/GICHelper.cpp

- std::string string(isl_printer_get_str(p));
+ char *char_str = isl_printer_get_str(p);
+ std::string string(char_str);
+ free(char_str);

This got me wondering: If this were compiled with exceptions it
wouldn't be safe (std::string's ctor could throw & then the free
wouldn't be called), but I know LLVM doesn't use exceptions in its
codebase.

Are exceptions actually disabled in the build? (I assume so)
How are memory allocation failures handled?
How do the standard library types function in the absence of
exceptions? (I've seen Howard Hinnant checking in changes to libc++ to
support cases where exceptions are disabled & I was wondering what
sort of semantics he (& libstdc++ too) provide when exceptions are
disabled).

- David

- std::string string(isl_printer_get_str(p));
+ char *char_str = isl_printer_get_str(p);
+ std::string string(char_str);
+ free(char_str);

This got me wondering: If this were compiled with exceptions it
wouldn't be safe (std::string's ctor could throw& then the free
wouldn't be called), but I know LLVM doesn't use exceptions in its
codebase.

You are right. Even though it would not yield to unexpected behavior, we would have a memory leak.

Are exceptions actually disabled in the build? (I assume so)

At least my build uses -fno-exceptions

How are memory allocation failures handled?

Interesting question. I must admit in this code they are not handled at all. I would be very interested in how other people would handle this.

How do the standard library types function in the absence of
exceptions? (I've seen Howard Hinnant checking in changes to libc++ to
support cases where exceptions are disabled& I was wondering what
sort of semantics he (& libstdc++ too) provide when exceptions are
disabled).

Again a very interesting question. I assume for explicit allocations with 'new' libstdc++ would return a NULL pointer (instead of throwing an exception).

str::string *str = new std::string("Hallo");

However, I have no idea what happens in the case of:

str::string str("Hallo);

Tobi