Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gccgo: internal compiler error for invalid array type #13486

Closed
griesemer opened this issue Dec 4, 2015 · 2 comments
Closed

gccgo: internal compiler error for invalid array type #13486

griesemer opened this issue Dec 4, 2015 · 2 comments
Milestone

Comments

@griesemer
Copy link
Contributor

package main
type a [10]int
type b [10.0]int
//type c [float64(10)]int
type d [complex(10, 0)]int
//type e [complex128(complex(10, 0))]int
func main(){}

gccgo crashes with an internal error for both of the invalid declarations of c and e:

go1: internal compiler error: in wide_int_to_tree, at tree.c:1468
0xda01eb wide_int_to_tree(tree_node*, generic_wide_int<wide_int_ref_storage<false> > const&)
    /tmp/go-build-release/gccgo-srcdir/gcc/tree.c:1468
0xda156d double_int_to_tree(tree_node*, double_int)
    /tmp/go-build-release/gccgo-srcdir/gcc/tree.c:1300
0x5fe24a Gcc_backend::integer_constant_expression(Btype*, __mpz_struct*)
    /tmp/go-build-release/gccgo-srcdir/gcc/go/go-gcc.cc:1226
0x6748ae Array_type::get_backend_length(Gogo*)
    /tmp/go-build-release/gccgo-srcdir/gcc/go/gofrontend/types.cc:6152
0x6774fc Named_type::convert(Gogo*)
    /tmp/go-build-release/gccgo-srcdir/gcc/go/gofrontend/types.cc:8842
0x60a6e2 Gogo::convert_named_types_in_bindings(Bindings*)
    /tmp/go-build-release/gccgo-srcdir/gcc/go/gofrontend/gogo.cc:4546
0x60fd8f Gogo::convert_named_types()
    /tmp/go-build-release/gccgo-srcdir/gcc/go/gofrontend/gogo.cc:4508
0x6083d7 go_parse_input_files(char const**, unsigned int, bool, bool)
    /tmp/go-build-release/gccgo-srcdir/gcc/go/gofrontend/go.cc:127
0x603f4f go_langhook_parse_file
    /tmp/go-build-release/gccgo-srcdir/gcc/go/go-lang.c:295

For a discussion see also #13485.

Furthermore, for this program:

package main
type a [10]int                        
type b [10.0]int                      
var c [float64(10)]int               
type d [complex(10, 0)]int            
var e [complex128(complex(10, 0))]int
func main(){ println(c[0]) }

(var instead of type declarations for c, e), the compiler accepts it without complaints even though the variable c is used.

@ianlancetaylor
Copy link
Contributor

CC @thanm Low priority gofrontend crash-on-invalid.

@thanm thanm assigned thanm and unassigned paranoiacblack Feb 5, 2018
@gopherbot
Copy link

Change https://golang.org/cl/91975 mentions this issue: compiler: avoid crashing on invalid non-integer array length

hubot pushed a commit to gcc-mirror/gcc that referenced this issue May 3, 2018
    
    Tweak the array type checking code to avoid crashing on array types
    whose length expressions are explicit non-integer types (for example,
    "float64(10)"). If such constructs are seen, issue an "invalid array
    bound" error.
    
    Fixes golang/go#13486.
    
    Reviewed-on: https://go-review.googlesource.com/91975


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@259900 138bc75d-0d04-0410-961f-82ee72b054a4
@golang golang locked and limited conversation to collaborators May 4, 2019
asiekierka pushed a commit to WonderfulToolchain/gcc-ia16 that referenced this issue May 16, 2022
    
    Tweak the array type checking code to avoid crashing on array types
    whose length expressions are explicit non-integer types (for example,
    "float64(10)"). If such constructs are seen, issue an "invalid array
    bound" error.
    
    Fixes golang/go#13486.
    
    Reviewed-on: https://go-review.googlesource.com/91975

From-SVN: r259900
@rsc rsc unassigned thanm Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants