Source file test/fixedbugs/issue11674.go

     1  // errorcheck
     2  
     3  // Copyright 2017 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 11674: cmd/compile: does not diagnose constant division by
     8  // zero
     9  
    10  package p
    11  
    12  const x complex64 = 0
    13  const y complex128 = 0
    14  
    15  var _ = x / 1e-20
    16  var _ = x / 1e-50   // GC_ERROR "division by zero"
    17  var _ = x / 1e-1000 // GC_ERROR "division by zero"
    18  var _ = x / 1e-20i
    19  var _ = x / 1e-50i   // GC_ERROR "division by zero"
    20  var _ = x / 1e-1000i // GC_ERROR "division by zero"
    21  
    22  var _ = x / 1e-45 // smallest positive float32
    23  
    24  var _ = x / (1e-20 + 1e-20i)
    25  var _ = x / (1e-50 + 1e-20i)
    26  var _ = x / (1e-20 + 1e-50i)
    27  var _ = x / (1e-50 + 1e-50i)     // GC_ERROR "division by zero"
    28  var _ = x / (1e-1000 + 1e-1000i) // GC_ERROR "division by zero"
    29  
    30  var _ = y / 1e-50
    31  var _ = y / 1e-1000 // GC_ERROR "division by zero"
    32  var _ = y / 1e-50i
    33  var _ = y / 1e-1000i // GC_ERROR "division by zero"
    34  
    35  var _ = y / 5e-324 // smallest positive float64
    36  
    37  var _ = y / (1e-50 + 1e-50)
    38  var _ = y / (1e-1000 + 1e-50i)
    39  var _ = y / (1e-50 + 1e-1000i)
    40  var _ = y / (1e-1000 + 1e-1000i) // GC_ERROR "division by zero"
    41  

View as plain text