Skip to content

WASM “if...else” doc: What happens if the value is not 0 or 1? (incomplete information) #20193

@AntonioNoack

Description

@AntonioNoack

MDN URL

https://developer.mozilla.org/en-US/docs/WebAssembly/Reference/Control_flow/if...else

What specific section or headline is this issue about?

The description

What information was incorrect, unhelpful, or incomplete?

It is not explained what happens if the value is not 0 or 1.
Often, null checks are practical, and in low level languages like C, it is ok to write if(ptr) ...

Is this allowed in WASM, or undefined behavior?

What did you expect to see?

The answer that it is allowed.
To quote from the specs:

If c is non-zero, then Execute the block instruction instr_1
Else Execute the block instruction instr_2

Section 4.4.8.5. of https://webassembly.github.io/spec/core/bikeshed/#control-instructions%E2%91%A4

Do you have any supporting links, references, or citations?

https://webassembly.github.io/spec/core/bikeshed/#control-instructions%E2%91%A4

Do you have anything more you want to share?

No response

MDN metadata

Page report details

Metadata

Metadata

Assignees

Labels

Content:wasmWebAssembly docshelp wantedIf you know something about this topic, we would love your help!

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions