mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 03:53:42 +00:00
compiler: insert nil checks when storing to a pointer
This does increase code size, but it is necessary to avoid undefined behavior.
This commit is contained in:
committed by
Ron Evans
parent
371c468e8e
commit
3c2639ad55
@@ -1054,6 +1054,7 @@ func (c *Compiler) parseInstr(frame *Frame, instr ssa.Instruction) {
|
||||
case *ssa.Store:
|
||||
llvmAddr := c.getValue(frame, instr.Addr)
|
||||
llvmVal := c.getValue(frame, instr.Val)
|
||||
c.emitNilCheck(frame, llvmAddr, "store")
|
||||
if c.targetData.TypeAllocSize(llvmVal.Type()) == 0 {
|
||||
// nothing to store
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user