Skip to content

UnityFail() is marked as noreturn but it actually returns when UNITY_EXCLUDE_SETJMP_H is defined #507

@alecoding

Description

@alecoding

UnityFail() is marked as noreturn but it actually returns when UNITY_EXCLUDE_SETJMP_H is defined. This issue produces a compilation warning and an exception on test failures.

The code flow that produces the issue is described below, In the declaration we have the noreturn attribute:

void UnityFail(const char* message, const UNITY_LINE_TYPE line) UNITY_FUNCTION_ATTR(noreturn);

but the implementation can actually return if UNITY_EXCLUDE_SETJMP_H is defined:

void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line)
{
    RETURN_IF_FAIL_OR_IGNORE;

   [...]

   UNITY_IGNORE_AND_BAIL;
}

because of

#define RETURN_IF_FAIL_OR_IGNORE if (Unity.CurrentTestFailed || Unity.CurrentTestIgnored) TEST_ABORT()

and

#ifndef UNITY_EXCLUDE_SETJMP_H
#define TEST_PROTECT() (setjmp(Unity.AbortFrame) == 0)
#define TEST_ABORT() longjmp(Unity.AbortFrame, 1)
#else
#define TEST_PROTECT() 1
#define TEST_ABORT() return
#endif

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