[Bug go/65134] gccgo ignores the attribute "constructor" in a subdirectory
e29253 at jp dot ibm.com
gcc-bugzilla@gcc.gnu.org
Sat Feb 21 03:25:00 GMT 2015
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()?
More information about the Gcc-bugs
mailing list