https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65134

--- Comment #2 from Tatsushi Inagaki <e29253 at jp dot ibm.com> ---
(In reply to Ian Lance Taylor from comment #1)
> It's pretty ugly, but a workaround is to drop something like this into
> sub.go:
> 
> var AlwaysFalse bool
> func init() {
>       if AlwaysFalse {
>               C.init()
>       }
> }
> 
> The idea is to force in something that refers to the function that the
> compiler and linker aren't smart enough to discard.

Thank you very much for your suggestion. Don't we have to take special care at
declaration or assignment of AlwaysFalse, so that the compiler will not
eliminate the never-taken branch to C.init()?

Reply via email to