What data types accept '{default:} form of initialization

What set of datatypes (arrays/structures/queues} accept this form of initialization where you could specify -

<some data type, name> = '{default:0};

I seem to be facing an error when using such a statement on bounded queues.

In reply to kernalmode1:

It always helps to show the code producing the error and the error message.

The LRM does not specifically exclude a default value in an assignment pattern for any type. However, it makes no sense to use it with a queue or dynamic array as there can never be unmatched elements that would use that default value.

In reply to dave_59:

Apologies. Here is the error (this is on edaplayground, not sure if it is an issue due to tool being outdated)

This declaration is inside of a class.

int q[$:3] = '{default:3};
$display (“%p”, t.q);

With tool A:

Error-[IAP] Illegal assignment pattern
testbench.sv, 12
test, “'{default:3}”
Assignment pattern is illegal due to: Assignment pattern to dynamic
array/queue of unknown size.
Write the Assignment Pattern using only positional and replicated notation.
No type/default literals are allowed here.

With tool B: just an empty queue, no error

'{}

With tool C:

ERROR VCP7051 “Array literals with keys cannot be assigned to dynamic arrays or queues.” “testbench.sv”

In reply to dave_59:

Could you please also elaborate on what you mean by
“as there can never be unmatched elements that would use that default value.”

In reply to kernalmode1:

A bounded queue behaves the same as a unbounded queue, except that you cannot allocate more elements beyond the upper bound. There is no minimum size or fixed size.

When using an assignment pattern to a queue or dynamic array, you are specifying the exact number of elements to be allocated. Just because the queue is bounded does not automatically allocate extra elements to fill up the queue.

In reply to dave_59:

That is exactly the point I was trying to make. Bounded queues should behave the same as unbounded or any other unpacked array that accepts the '{default:} form of initialization. Seems like it is not the case.

In reply to kernalmode1:

If you had

int q[$] = '{default:3};

What do you expect the behavior to be?

In reply to dave_59:

Point taken Dave. I understand.

Thanks.