Skip to content

Comptime IDE crash from Comptime-generated Constant #2451

Description

@hunterbridges

We have started getting frequent IDE crashes in our codebase, which are still occurring on latest nightly.

I ran IDE in Debug, and it appears to be hitting an assert in BeefIRBuilder.cpp:2601

BF_ASSERT(irValue.mId >= 0);

Inspecting surrounding state, it appears to be hitting the assert when trying to generate IR for the comptime-generated constant Hero.INSTANCE_SIZE, which is emitted as such (in the Hero class type):

const uint32 RSDK_INSTANCE_SIZE = Memory.AlignPOW2((.)typeof(Self).InstanceStride);

For context, Memory.AlignPOW2 is a ConstEval function defined as:

	[Comptime(ConstEval = true)]
	public static uint32 AlignPOW2(uint32 size)
	{
		uint32 v = size;

		v--;
		v |= v >> 1;
		v |= v >> 2;
		v |= v >> 4;
		v |= v >> 8;
		v |= v >> 16;
		v++;

		return v;
	}

For additional context, Hero is a class that has a fair bit of extensions.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions