]> Cypherpunks.ru repositories - gostls13.git/blob - test/fixedbugs/issue23522.go
cmd/compile/internal/inline: score call sites exposed by inlines
[gostls13.git] / test / fixedbugs / issue23522.go
1 // run
2
3 // Copyright 2018 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
6
7 package main
8
9 import (
10         "math"
11 )
12
13 type S struct {
14         u int64
15         n int32
16 }
17
18 func F1(f float64) *S {
19         s := f
20         pf := math.Copysign(f, 1)
21         u := math.Floor(pf)
22         return &S{
23                 u: int64(math.Copysign(u, s)),
24                 n: int32(math.Copysign((pf-u)*1e9, s)),
25         }
26 }
27
28 func F2(f float64) *S {
29         s := f
30         f = math.Copysign(f, 1)
31         u := math.Floor(f)
32         return &S{
33                 u: int64(math.Copysign(u, s)),
34                 n: int32(math.Copysign((f-u)*1e9, s)),
35         }
36 }
37
38 func main() {
39         s1 := F1(-1)
40         s2 := F2(-1)
41         if *s1 != *s2 {
42                 println("F1:", s1.u, s1.n)
43                 println("F2:", s2.u, s2.n)
44                 panic("different")
45         }
46 }