Godbolt is great for checking stuff like this: https://www.godbolt.org/z/vj1q6e
Clang should give a warning (even without evelated warning level), and the undefined behaviour sanitizer also complains. Since this is C++ anyway (not C), I've seen a nice solution for this type of stuff in TinyXML2, a special special pointer wrapper class which allows safe method chaining, see here: http://www.grinninglizard.com/tinyxmldocs/classTiXmlHandle.html On Thursday, 25 February 2021 at 07:57:58 UTC+1 caiiiycuk wrote: > Hi, I have a big code base that uses this pattern: > > ``` > > int String::intValue() const { > if (!this) { > return 0; > } > > // ... > } > > int count = dict->stringForKey("count")->intValue(); > > ``` > > If *dict->stringForKey* returns *nullptr* then wasm is crashed, but > native works fine. > This code also worked fine with old versions of emscipten. > > I understand that this is ugly pattern, but I am curious if it can work as > before? > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/8baf4b81-f803-40c2-80f6-bdbcb8a6ddb4n%40googlegroups.com.
