ispc / ispc/ispc

assert() feature request

Open
#576 1 comment 0 reactions 0 assignees View on GitHub
C/C++ Compatibility Frontend / Parser
Dominant language
C++
Stars
3k
Forks
352
PR merge metrics
No merged PRs in 30d

Description

One handy trick I learned long ago (thanks Mark Leone!) was to do this:

if (failure_case) {
assert(!"Unknown material type")
}

I assume this works because the string resolves to a 'true' which inverted gives the false which triggers the assert. The handy bit is that when the program exits you get:

a.out: blah.cpp:10: int main(): Assertion `!"Unknown material type"' failed.

by which you basically get an assert with a reason / error message in one shot.

ISPC doesn't like the idea of making the string into a bool:

bsdf_demo.ispc:24:21: Error: syntax error, unexpected TOKEN_STRING_LITERAL.
Assert(!"Unknown material type");

Not a big priority request and maybe this would throw off other elements of the language but (IMO) it'd be handy nonetheless.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.