Skip to content

Commit 8b9b365

Browse files
cmd/compile: use exact constant in go_asm.h
Fixes #50523 Change-Id: Idab1b44d106250e9301d90ee6571f0ea51242dd9 Reviewed-on: https://go-review.googlesource.com/c/go/+/377074 Trust: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> Reviewed-by: Liz Fong-Jones <[email protected]> Reviewed-by: Emmanuel Odeke <[email protected]> Trust: Emmanuel Odeke <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Robert Griesemer <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent 55d10ac commit 8b9b365

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

src/cmd/compile/internal/gc/export.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func dumpasmhdr() {
3131
if t == constant.Float || t == constant.Complex {
3232
break
3333
}
34-
fmt.Fprintf(b, "#define const_%s %v\n", n.Sym().Name, n.Val())
34+
fmt.Fprintf(b, "#define const_%s %v\n", n.Sym().Name, n.Val().ExactString())
3535

3636
case ir.OTYPE:
3737
t := n.Type()

test/asmhdr.dir/main.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ const (
1616
bigInt = 0xffffffffffffffff
1717

1818
stringVal = "test"
19+
20+
longStringVal = "this_is_a_string_constant_longer_than_seventy_characters_which_used_to_fail_see_issue_50253"
1921
)
2022

2123
var (
22-
smallIntAsm int64
23-
bigIntAsm uint64
24-
stringAsm [len(stringVal)]byte
24+
smallIntAsm int64
25+
bigIntAsm uint64
26+
stringAsm [len(stringVal)]byte
27+
longStringAsm [len(longStringVal)]byte
2528
)
2629

2730
type typ struct {
@@ -46,6 +49,9 @@ func main() {
4649
if stringVal != string(stringAsm[:]) {
4750
println("stringVal", stringVal, "!=", string(stringAsm[:]))
4851
}
52+
if longStringVal != string(longStringAsm[:]) {
53+
println("longStringVal", longStringVal, "!=", string(longStringAsm[:]))
54+
}
4955

5056
// We also include boolean consts in go_asm.h, but they're
5157
// defined to be "true" or "false", and it's not clear how to

test/asmhdr.dir/main.s

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ GLOBL ·bigIntAsm(SB),RODATA,$8
1414
DATA ·stringAsm(SB)/4, $const_stringVal
1515
GLOBL ·stringAsm(SB),RODATA,$4
1616

17+
DATA ·longStringAsm(SB)/91, $const_longStringVal
18+
GLOBL ·longStringAsm(SB),RODATA,$91
19+
1720
DATA ·typSize(SB)/8, $typ__size
1821
GLOBL ·typSize(SB),RODATA,$8
1922

0 commit comments

Comments
 (0)