Thread overview
HELP! DMD Asserts while generating DI files.
Jan 23, 2012
Adam Wilson
Jan 26, 2012
kenji hara
Jan 26, 2012
Adam Wilson
Feb 01, 2012
Martin Nowak
Feb 01, 2012
Adam Wilson
Feb 01, 2012
Martin Nowak
January 23, 2012
Does anyone have any idea why DMD would assert with the following assert on this code while building the druntime during DI generation?

Generating This DI file...
// D import file generated from 'src\core\bitop.d'
module core.bitop;
nothrow
{
	pure int bsf(size_t v);

	pure int bsr(size_t v);

	pure int bt(in size_t* p, size_t bitnum);

	int btc(size_t* p, size_t bitnum);
	int btr(size_t* p, size_t bitnum);
	int bts(size_t* p, size_t bitnum);
	pure uint bswap(uint v);

	ubyte inp(uint port_address);
	ushort inpw(uint port_address);
	uint inpl(uint port_address);
	ubyte outp(uint port_address, ubyte value);
	ushort outpw(uint port_address, ushort value);
	uint outpl(uint port_address, uint value);
	int popcnt(uint x);
	debug (UnitTest)
	{
	}
	uint bitswap(uint x);
	debug (UnitTest)
	{
	}
}

produces this assert in DMD: assert cast.c(2082) t1->ty == t2->ty
which appears to be the typeMerge function in cast.c

It doesn't do this on all DI files and I am at a loss as to any rhyme or reason for when it does assert. Perhaps someone with knowledge of the compiler internals could be of help...

Any ideas would be very helpful!

-- 
Adam Wilson
Project Coordinator
The Horizon Project
http://www.thehorizonproject.org/
January 26, 2012
What version do you use?
In 2.058head(commit f8887855), `dmd -H -c test.d` succeeds to compile
without DMD assertion.

Kenji Hara

2012/1/23 Adam Wilson <flyboynw@gmail.com>:
> Does anyone have any idea why DMD would assert with the following assert on this code while building the druntime during DI generation?
>
> Generating This DI file...
> // D import file generated from 'src\core\bitop.d'
> module core.bitop;
> nothrow
> {
>        pure int bsf(size_t v);
>
>        pure int bsr(size_t v);
>
>        pure int bt(in size_t* p, size_t bitnum);
>
>        int btc(size_t* p, size_t bitnum);
>        int btr(size_t* p, size_t bitnum);
>        int bts(size_t* p, size_t bitnum);
>        pure uint bswap(uint v);
>
>        ubyte inp(uint port_address);
>        ushort inpw(uint port_address);
>        uint inpl(uint port_address);
>        ubyte outp(uint port_address, ubyte value);
>        ushort outpw(uint port_address, ushort value);
>        uint outpl(uint port_address, uint value);
>        int popcnt(uint x);
>        debug (UnitTest)
>        {
>        }
>        uint bitswap(uint x);
>        debug (UnitTest)
>        {
>        }
> }
>
> produces this assert in DMD: assert cast.c(2082) t1->ty == t2->ty which appears to be the typeMerge function in cast.c
>
> It doesn't do this on all DI files and I am at a loss as to any rhyme or reason for when it does assert. Perhaps someone with knowledge of the compiler internals could be of help...
>
> Any ideas would be very helpful!
>
> --
> Adam Wilson
> Project Coordinator
> The Horizon Project
> http://www.thehorizonproject.org/
January 26, 2012
On Thu, 26 Jan 2012 06:33:12 -0800, kenji hara <k.hara.pg@gmail.com> wrote:

> What version do you use?
> In 2.058head(commit f8887855), `dmd -H -c test.d` succeeds to compile
> without DMD assertion.
>
> Kenji Hara
>
> 2012/1/23 Adam Wilson <flyboynw@gmail.com>:
>> Does anyone have any idea why DMD would assert with the following assert on
>> this code while building the druntime during DI generation?
>>
>> Generating This DI file...
>> // D import file generated from 'src\core\bitop.d'
>> module core.bitop;
>> nothrow
>> {
>>        pure int bsf(size_t v);
>>
>>        pure int bsr(size_t v);
>>
>>        pure int bt(in size_t* p, size_t bitnum);
>>
>>        int btc(size_t* p, size_t bitnum);
>>        int btr(size_t* p, size_t bitnum);
>>        int bts(size_t* p, size_t bitnum);
>>        pure uint bswap(uint v);
>>
>>        ubyte inp(uint port_address);
>>        ushort inpw(uint port_address);
>>        uint inpl(uint port_address);
>>        ubyte outp(uint port_address, ubyte value);
>>        ushort outpw(uint port_address, ushort value);
>>        uint outpl(uint port_address, uint value);
>>        int popcnt(uint x);
>>        debug (UnitTest)
>>        {
>>        }
>>        uint bitswap(uint x);
>>        debug (UnitTest)
>>        {
>>        }
>> }
>>
>> produces this assert in DMD: assert cast.c(2082) t1->ty == t2->ty
>> which appears to be the typeMerge function in cast.c
>>
>> It doesn't do this on all DI files and I am at a loss as to any rhyme or
>> reason for when it does assert. Perhaps someone with knowledge of the
>> compiler internals could be of help...
>>
>> Any ideas would be very helpful!
>>
>> --
>> Adam Wilson
>> Project Coordinator
>> The Horizon Project
>> http://www.thehorizonproject.org/

Hi Kenji,

It appears to be a problem related to my DI generation patch. But I don't know near enough about cast.c to reduce the problem quickly, my guess is that druntime and phobos are excepting something to exist in the DI that the patch strips out, but that's only a guess. As you can see, the DI file itself is generated without any errors, this assert seems to come afterwards. Does D export the .DI file then try to use it during compilation of the .D file?

-- 
Adam Wilson
Project Coordinator
The Horizon Project
http://www.thehorizonproject.org/
February 01, 2012
> Hi Kenji,
>
> It appears to be a problem related to my DI generation patch. But I don't know near enough about cast.c to reduce the problem quickly, my guess is that druntime and phobos are excepting something to exist in the DI that the patch strips out, but that's only a guess. As you can see, the DI file itself is generated without any errors, this assert seems to come afterwards. Does D export the .DI file then try to use it during compilation of the .D file?
>

No it doesn't.
February 01, 2012
On Tue, 31 Jan 2012 18:20:13 -0800, Martin Nowak <dawg@dawgfoto.de> wrote:

>> Hi Kenji,
>>
>> It appears to be a problem related to my DI generation patch. But I don't know near enough about cast.c to reduce the problem quickly, my guess is that druntime and phobos are excepting something to exist in the DI that the patch strips out, but that's only a guess. As you can see, the DI file itself is generated without any errors, this assert seems to come afterwards. Does D export the .DI file then try to use it during compilation of the .D file?
>>
>
> No it doesn't.

That makes this even weirder then, because the DI seems to generate itself just fine and the problems are all afterwards. Well, I've got an email out to Walter to see what he has to say on the subject.

-- 
Adam Wilson
Project Coordinator
The Horizon Project
http://www.thehorizonproject.org/
February 01, 2012
On Wed, 01 Feb 2012 06:46:42 +0100, Adam Wilson <flyboynw@gmail.com> wrote:

> On Tue, 31 Jan 2012 18:20:13 -0800, Martin Nowak <dawg@dawgfoto.de> wrote:
>
>>> Hi Kenji,
>>>
>>> It appears to be a problem related to my DI generation patch. But I don't know near enough about cast.c to reduce the problem quickly, my guess is that druntime and phobos are excepting something to exist in the DI that the patch strips out, but that's only a guess. As you can see, the DI file itself is generated without any errors, this assert seems to come afterwards. Does D export the .DI file then try to use it during compilation of the .D file?
>>>
>>
>> No it doesn't.
>
> That makes this even weirder then, because the DI seems to generate itself just fine and the problems are all afterwards. Well, I've got an email out to Walter to see what he has to say on the subject.
>

This would be a lot simpler if you'd show us the modifications for DI gen.