I’m pretty sure that calling a method on a null pointer is undefined
behavior. My guess is that at some point LLVM started recognizing and
optimizing away this UB, which is why you’re seeing different behavior with
newer versions of Emscripten.

On Wed, Feb 24, 2021 at 22:57 Александр Гурьянов <[email protected]>
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/CAKOm%3DVF2kSJEthLuvS7afsPFprxehG%3DXJxppdHxMA6a8rvUyAw%40mail.gmail.com
> <https://groups.google.com/d/msgid/emscripten-discuss/CAKOm%3DVF2kSJEthLuvS7afsPFprxehG%3DXJxppdHxMA6a8rvUyAw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
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/CAJZD_EWr1ZkGVzXLWVHf9FGK137UUUZut%3Dce5GbbOU-FLLUXbA%40mail.gmail.com.

Reply via email to