compiler: fix "fragment covers entire variable" bug

This bug could sometimes be triggered by syscall/js code it seems. But
it's a generic bug, not specific to WebAssembly.
This commit is contained in:
Ayke van Laethem
2021-03-28 15:08:01 +02:00
committed by Ron Evans
parent 4be9802d26
commit b44d41d9ec
6 changed files with 45 additions and 16 deletions
+17
View File
@@ -74,6 +74,14 @@ func main() {
//Test deferred builtins
testDeferBuiltinClose()
testDeferBuiltinDelete()
// Check for issue 1304.
// There are two fields in this struct, one of which is zero-length so the
// other covers the entire struct. This led to a verification error for
// debug info, which used DW_OP_LLVM_fragment for a field that practically
// covered the entire variable.
var x issue1304
x.call()
}
func runFunc(f func(int), arg int) {
@@ -211,3 +219,12 @@ func foo(bar *Bar) error {
return nil
}
type issue1304 struct {
a [0]int // zero-length field
b int // field 'b' covers entire struct
}
func (x issue1304) call() {
// nothing to do
}