Skip to content

Improvement: better diagnostics for undefined behavior #134372

@pmor13

Description

@pmor13

Compiling this code:

void foo(void)
{
    struct x* y;
    *y;
}

with -O3 -std=c11 -pedantic -Wall -Wextra leads to:

<source>:4:5: error: incomplete type 'struct x' where a complete type is required
    4 |     *y;

For people who learned C11 by reading C11 this diagnostic may be confusing because C11 does not require the operand of the unary * operator to be pointer type, which points to an object of a complete type.

Expected diagnostics:

<source>:4:5: error: lvalue conversion: lvalue has an incomplete type
    4 |     *y;

@AaronBallman

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerquality-of-implementationwontfixIssue is real, but we can't or won't fix it. Not invalid

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions