diff --git a/source/fuzz/transformation_access_chain.cpp b/source/fuzz/transformation_access_chain.cpp index ff17c3685..f805bab71 100644 --- a/source/fuzz/transformation_access_chain.cpp +++ b/source/fuzz/transformation_access_chain.cpp @@ -74,9 +74,9 @@ bool TransformationAccessChain::IsApplicable( switch (pointer->opcode()) { case SpvOpConstantNull: case SpvOpUndef: - // TODO(https://github.com/KhronosGroup/SPIRV-Tools/issues/3185): When - // fuzzing for real we would like an 'assert(false)' here. But we also - // want to be able to write negative unit tests. + assert( + false && + "Access chains should not be created from null/undefined pointers"); return false; default: break; diff --git a/test/fuzz/transformation_access_chain_test.cpp b/test/fuzz/transformation_access_chain_test.cpp index 443c31c79..905e6c2de 100644 --- a/test/fuzz/transformation_access_chain_test.cpp +++ b/test/fuzz/transformation_access_chain_test.cpp @@ -183,15 +183,23 @@ TEST(TransformationAccessChainTest, BasicTest) { 100, 43, {80}, MakeInstructionDescriptor(24, SpvOpLoad, 100)) .IsApplicable(context.get(), transformation_context)); +#ifndef NDEBUG // Bad: pointer is null - ASSERT_FALSE(TransformationAccessChain( - 100, 45, {80}, MakeInstructionDescriptor(24, SpvOpLoad, 0)) - .IsApplicable(context.get(), transformation_context)); + ASSERT_DEATH( + TransformationAccessChain(100, 45, {80}, + MakeInstructionDescriptor(24, SpvOpLoad, 0)) + .IsApplicable(context.get(), transformation_context), + "Access chains should not be created from null/undefined pointers"); +#endif +#ifndef NDEBUG // Bad: pointer is undef - ASSERT_FALSE(TransformationAccessChain( - 100, 46, {80}, MakeInstructionDescriptor(24, SpvOpLoad, 0)) - .IsApplicable(context.get(), transformation_context)); + ASSERT_DEATH( + TransformationAccessChain(100, 46, {80}, + MakeInstructionDescriptor(24, SpvOpLoad, 0)) + .IsApplicable(context.get(), transformation_context), + "Access chains should not be created from null/undefined pointers"); +#endif // Bad: pointer to result type does not exist ASSERT_FALSE(TransformationAccessChain(