[gambit-list] When gsc makes gcc unhappy with symbol redefinitions

Dimitris Vyzovitis vyzo at hackzen.org
Wed May 10 08:34:10 EDT 2017


Aha! Thanks for catching this Marc -- I was quite certain there was a real
issue here!

The problem comes from generative structs using gensym for their symbol id
and quotes are not interned by the (gxc) compiler. This doesn't happen with
defstruct at module level, but my srfi/9 implementation emits a gensym
without checking if it's in module scope.
.
So what happened here is that gxc (the gerbil compiler) with its new shiny
optimizer inlined the struct  operation, but the record definition was a
gensym coming from my srfi/9 define-record.

Macro at fault!

-- vyzo

On Wed, May 10, 2017 at 3:12 PM, Marc Feeley <feeley at iro.umontreal.ca>
wrote:

> In your file I see these expressions:
>
>   (define std/srfi/14#:char-set
>     (make-struct-type '#::char-set3224 '#f '1 ':char-set '((fields: s))
> '#f))
>
>   (if (##structure-instance-of? _bcs3729_ '#::char-set3224) ...)
>
> Note that #::char-set3224 appears multiple times, and it is an
> *uninterned* symbol.  When the parser reads these uninterned symbols,
> multiple independent symbols with the same name are created.  So your code
> is faulty because you will not get the same uninterned symbol (as you
> probably intended).
>
> The error message you are getting is due to the Gambit compiler not
> handling this faulty case well.  I will add a better handling of this (not
> generating identically named #defines) but still that will not make your
> code work as intended.
>
> Marc
>
>
>
> > On May 10, 2017, at 6:19 AM, Dimitris Vyzovitis <vyzo at hackzen.org>
> wrote:
> >
> > Bringing this up to the list, because this is an interesting output from
> gsc and the file attachment feature of github doesn't work.
> > So I have this file which is the compiled output of gxc for srfi-14,
> with some optimizations applied (namely inlining of struct ops in this
> case).
> > This results to gsc generating a bunch of cascading redefinitions, which
> result in gcc warnings.
> >
> > > gsc 14__0.scm
> > 14__0.c:337:0: warning: "___SYM__3a_char_2d_set3224" redefined
> >  #define ___SYM__3a_char_2d_set3224 ___SYM(3,___S__3a_char_2d_set3224)
> >  ^
> > 14__0.c:336:0: note: this is the location of the previous definition
> >  #define ___SYM__3a_char_2d_set3224 ___SYM(2,___S__3a_char_2d_set3224)
> >  ^
> > 14__0.c:338:0: warning: "___SYM__3a_char_2d_set3224" redefined
> >  #define ___SYM__3a_char_2d_set3224 ___SYM(4,___S__3a_char_2d_set3224)
> >  ^
> > 14__0.c:337:0: note: this is the location of the previous definition
> >  #define ___SYM__3a_char_2d_set3224 ___SYM(3,___S__3a_char_2d_set3224)
> >  ^
> > 14__0.c:339:0: warning: "___SYM__3a_char_2d_set3224" redefined
> >  #define ___SYM__3a_char_2d_set3224 ___SYM(5,___S__3a_char_2d_set3224)
> >  ^
> > 14__0.c:338:0: note: this is the location of the previous definition
> >  #define ___SYM__3a_char_2d_set3224 ___SYM(4,___S__3a_char_2d_set3224)
> >  ^
> >
> > So what's up with that?
> >
> > -- vyzo
> > <14__0.scm>_______________________________________________
> > Gambit-list mailing list
> > Gambit-list at iro.umontreal.ca
> > https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20170510/1267da68/attachment.htm>


More information about the Gambit-list mailing list