File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,35 @@ information in Go binaries.
9
9
DWARF 5 generation is gated by the "dwarf5" GOEXPERIMENT; this
10
10
functionality can be disabled (for now) using GOEXPERIMENT=nodwarf5.
11
11
12
+ <!-- https://go.dev/issue/72860, CL 657715 -->
13
+
14
+ The compiler [ has been fixed] ( /cl/657715 )
15
+ to ensure that nil pointer checks are performed promptly. Programs like the following,
16
+ which used to execute successfully, will now panic with a nil-pointer exception:
17
+
18
+ ```
19
+ package main
20
+
21
+ import "os"
22
+
23
+ func main() {
24
+ f, err := os.Open("nonExistentFile")
25
+ name := f.Name()
26
+ if err != nil {
27
+ return
28
+ }
29
+ println(name)
30
+ }
31
+ ```
32
+
33
+ This program is incorrect in that it uses the result of ` os.Open ` before checking
34
+ the error. The main result of ` os.Open ` can be a nil pointer if the error result is non-nil.
35
+ But because of [ a compiler bug] ( /issue/72860 ) , this program ran successfully under
36
+ Go versions 1.21 through 1.24 (in violation of the Go spec). It will no longer run
37
+ successfully in Go 1.25. If this change is affecting your code, the solution is to put
38
+ the non-nil error check earlier in your code, preferrably immediately after
39
+ the error-generating statement.
40
+
12
41
## Assembler {#assembler}
13
42
14
43
## Linker {#linker}
You can’t perform that action at this time.
0 commit comments