1// run
2
3// Copyright 2014 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// Issue 8325: corrupted byte operations during optimization
8// pass.
9
10package main
11
12const alphanum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
13
14func main() {
15	var bytes = []byte{10, 20, 30, 40, 50}
16
17	for i, b := range bytes {
18		bytes[i] = alphanum[b%byte(len(alphanum))]
19	}
20
21	for _, b := range bytes {
22		switch {
23		case '0' <= b && b <= '9',
24			'A' <= b && b <= 'Z':
25		default:
26			println("found a bad character", string(b))
27			panic("BUG")
28		}
29
30	}
31}
32