Skip to content

Commit 3ba1ec7

Browse files
README nit
1 parent 14c40f9 commit 3ba1ec7

File tree

1 file changed

+24
-22
lines changed

1 file changed

+24
-22
lines changed

README.md

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,32 @@ if (*x_00 == '+') {
5555
As implemented in `src/cmd/compile/internal/ssagen/ssa.go`, we apply a source-location-based filtering for overflow detection. This ensures overflow detection is applied only to user code and target applications (like security audits of external codebases) while excluding standard library and third-party dependencies.
5656
Each arithmetic operation (`intAdd`, `intSub`, `intMul`, `intDiv`) checks the actual source file location using `n.Pos()` and `base.Ctxt.PosTable.Pos(pos).Filename()`. Operations from files containing `/go-panikint/src/`, `/pkg/mod/`, `/vendor/` are automatically excluded and standard library packages (`runtime`, `sync`, `os`, `syscall`, etc.) / internal packages (`internal/*`) are excluded during compiler build.
5757

58+
### Suppressing false positives
59+
60+
Add a comment marker on the same line as the operation or the line immediately above to mark a bug as false positive, so that the compiler won't panic on the arithmetic or truncation issue.:
61+
62+
- Overflow/underflow: `overflow_false_positive`
63+
- Truncation: `truncation_false_positive`
64+
65+
Example:
66+
67+
```go
68+
// This is an overflow, but it's on purpose so we don't care flagging it
69+
// overflow_false_positive
70+
intentional_overflow := a + b
71+
72+
// Same for my buggy truncation
73+
// truncation_false_positive
74+
x := uint8(big)
75+
76+
// Also work on the same line
77+
sum2 := a + b // overflow_false_positive
78+
x2 := uint8(big) // truncation_false_positive
79+
```
80+
5881
### Testing
5982

60-
You can run theÒ test suite in `tests/` with:
83+
You can run the test suite in `tests/` with:
6184

6285
```bash
6386
cd tests/;
@@ -135,27 +158,6 @@ func main() {
135158
}
136159
```
137160

138-
### Suppressing false positives
139-
140-
Add a comment marker on the same line as the operation or the line immediately above to mark a bug as false positive, so that the compiler won't panic on the arithmetic or truncation issue.:
141-
142-
- Overflow/underflow: `overflow_false_positive`
143-
- Truncation: `truncation_false_positive`
144-
145-
Example:
146-
147-
```go
148-
// overflow_false_positive
149-
sum := a + b
150-
151-
// truncation_false_positive
152-
x := uint8(big)
153-
154-
sum2 := a + b // overflow_false_positive
155-
x2 := uint8(big) // truncation_false_positive
156-
```
157-
158-
159161
**Expected output:**
160162

161163
```bash

0 commit comments

Comments
 (0)