Source file test/fixedbugs/issue8325.go

     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  
    10  package main
    11  
    12  const alphanum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    13  
    14  func 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  

View as plain text