Request for Comment assert(__ctfe)

Stefan Koch uplink.coder at googlemail.com
Tue Apr 7 12:09:48 UTC 2020


On Tuesday, 7 April 2020 at 11:32:27 UTC, Johannes Pfau wrote:
>
> And the most important thing: This will vastly improve betterC 
> / nogc code:
>
> --------------------
> string generateMixin(T)(string b)
> {
>     assert(__ctfe);
>     return T.stringof ~ " " ~ b ~ ";";
> }
>
> void main() @nogc
> {
>     mixin(generateMixin!string("b"));
> }
> --------------------


I can confirm with the patch there are no template-instances in 
the object file

with patch:
0000000000000000 R _D6t_ctfe12__ModuleInfoZ
                  U _d_dso_registry
0000000000000000 W _Dmain
                  U _Dmain
                  U _d_run_main
                  U _GLOBAL_OFFSET_TABLE_
0000000000000000 W main
                  U _main
                  U __start_minfo
                  U __stop_minfo

without patch:
                  U _D12TypeInfo_Aya6__initZ
0000000000000000 R _D6t_ctfe12__ModuleInfoZ
0000000000000000 W _D6t_ctfe__T13generateMixinTAyaZQuFNaNbNfQnZQq
                  U _d_arraycatnTX
                  U _d_assertp
                  U _d_dso_registry
0000000000000000 W _Dmain
                  U _Dmain
                  U _d_run_main
                  U _GLOBAL_OFFSET_TABLE_
0000000000000000 W main
                  U _main
                  U __start_minfo
                  U __stop_minfo
0000000000000000 r _TMP0
0000000000000009 r _TMP1
000000000000000b r _TMP2



More information about the Digitalmars-d mailing list