www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - DMD 0.130: Template modules cannot use a different -release setting than a module which uses it

reply Burton Radons <burton-radons smocky.com> writes:
I don't think this long-standing bug has been codified in a formal bug post,
so here's one.

This is the content of f.d:

        import g;

        void main ()
        {
                T! () ();
        }

This is the content of g.d:

        template T ()
        {
                void T ()
                {
                        assert (0);
                }
        }

Here is a compilation script for these modules:

        dmd f.d -c
        dmd g.d f.obj -release

The linking stage fails with the error message on Linux:

        f.o(.gnu.linkonce.t_D1g9Template_8TemplateFZv+0x9): In function
`_D1g9Template_8TemplateFZv':
: undefined reference to `_assert_1g'

It should compile properly.  The cause is that f.d and g.d are compiled with
different values for "-release".  DMD should produce module assertion
functions regardless of the setting of "-release".
Sep 07 2005
next sibling parent =?ISO-8859-1?Q?Thomas_K=FChne?= <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Burton Radons schrieb:

 I don't think this long-standing bug has been codified in a formal bug post,
 so here's one.
 
 This is the content of f.d:
 
         import g;
 
         void main ()
         {
                 T! () ();
         }
 
 This is the content of g.d:
 
         template T ()
         {
                 void T ()
                 {
                         assert (0);
                 }
         }
 
 Here is a compilation script for these modules:
 
         dmd f.d -c
         dmd g.d f.obj -release
 
 The linking stage fails with the error message on Linux:
 
         f.o(.gnu.linkonce.t_D1g9Template_8TemplateFZv+0x9): In function
 `_D1g9Template_8TemplateFZv':
 : undefined reference to `_assert_1g'
 
 It should compile properly.  The cause is that f.d and g.d are compiled with
 different values for "-release".  DMD should produce module assertion
 functions regardless of the setting of "-release".
Baiscally the same as the following complex test case: http://dstress.kuehne.cn/www/dstress.html#typeinfo_init_02 Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFDIn0b3w+/yD4P9tIRAt7uAKCQkOyE0IERqNPbx7vmogn5LMcA6gCgzWfx ht4zavr4wW82T9jYWgZK7fw= =NxHF -----END PGP SIGNATURE-----
Sep 09 2005
prev sibling parent Sean Kelly <sean f4.ca> writes:
In article <dfnpcd$16ad$1 digitaldaemon.com>, Burton Radons says...
I don't think this long-standing bug has been codified in a formal bug post,
so here's one.

This is the content of f.d:

        import g;

        void main ()
        {
                T! () ();
        }

This is the content of g.d:

        template T ()
        {
                void T ()
                {
                        assert (0);
                }
        }

Here is a compilation script for these modules:

        dmd f.d -c
        dmd g.d f.obj -release

The linking stage fails with the error message on Linux:

        f.o(.gnu.linkonce.t_D1g9Template_8TemplateFZv+0x9): In function
`_D1g9Template_8TemplateFZv':
: undefined reference to `_assert_1g'
I complained about this on the general forum recently. If the template module contains only template code, an easy fix is to always compile that module without -release specified. The object file will only contain the generated assert functions, and the template code generated by other builds will call or not call them as appropriate. This is what I've done for Ares. The real solution is probably to build debug and release versions of your libraries and direct users to link to the appropriate one, but that isn't feasible for me until DMD supports this for Phobos. Either way, it's a tad weird that all-template modules need to be compiled at all. Though that may simply be something I've gotten used to from C++. Sean
Sep 10 2005