# panic: runtime error: slice bounds out of range

- **ID:** `go/unsafe-string-conversion`
- **Domain:** go
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Converting a `[]byte` to `string` using `unsafe` without ensuring proper length, leading to out-of-bounds read.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 1.19 | active | — | — |
| 1.20 | active | — | — |

## Workarounds

1. **Use `string(b)` for safe conversion (copies)** (100% success)
   ```
   s := string(b)
// s is immutable copy
   ```
2. **Use `unsafe.String` with explicit length (Go 1.20+)** (80% success)
   ```
   s := unsafe.String(&b[0], len(b))
// but ensure b is not mutated
   ```

## Dead Ends

- **Using `*(*string)(unsafe.Pointer(&b))` directly** — String header may have wrong length if slice header changes. (90% fail)
- **Assuming zero-copy is always safe** — If slice is modified later, string becomes invalid. (70% fail)
