Skip to content

Problems with cgo translation. #1081

@gopherbot

Description

@gopherbot

by Bailey.D.R:

1. What is a short input program that triggers the error?

Here are two files making a package 'bug' The first, bug.h:

typedef int MyBool;

And the second, bug.go:

    package bug.go
    
    /*
     * #include "bug.h"
     *
     */
    type Bool MyBool

Funnily, when the go file is changed to:

    package bug.go
    
    // #include "bug.h"
    type Bool MyBool

the file compiles fine.

2. What is the full compiler output?

bug.go:10:11: expression C.MyBool used as type
panic: runtime error: invalid memory address or nil pointer dereference

panic PC=0x3b4c50
runtime.panic+0xb2 /Users/duane/go/src/pkg/runtime/proc.c:1015
    runtime.panic(0x0, 0x2681f)
panicstring+0x69 /Users/duane/go/src/pkg/runtime/runtime.c:83
    panicstring(0x10fa00, 0x3d7590)
sigpanic+0x148 /Users/duane/go/src/pkg/runtime/darwin/thread.c:460
    sigpanic()
main.*Package·rewriteRef+0xbff /Users/duane/go/src/cmd/cgo/gcc.go:443
    main.*Package·rewriteRef(0x7fff5fbffa44, 0x6, 0xa00000051, 0xb)
main.*Package·Translate+0x149 /Users/duane/go/src/cmd/cgo/gcc.go:72
    main.*Package·Translate(0x3c3d90, 0x3d5ba0, 0x3b0030, 0x100000000)
main.main+0x58a /Users/duane/go/src/cmd/cgo/main.go:152
    main.main()
mainstart+0xf /Users/duane/go/src/pkg/runtime/amd64/asm.s:78
    mainstart()
goexit /Users/duane/go/src/pkg/runtime/proc.c:145
    goexit()

3. What version of the compiler are you using?  (Run it with the -V flag.)

I'm running the version of cgo in the same build as "6g version 6080 release
release.2010-08-25".

Attachments:

  1. bug.h (20 bytes)
  2. bug.go (90 bytes)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions