Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

typeof_unqual — an unqualified type

C23 typeof_unqual derives a non-atomic, unqualified type from an expression or a type name.

Version: C23; repository compiler flag, production runtime not attested

Syntax

typeof_unqual(expression)
typeof_unqual(type-name)

typeof_unqual is a C23 type specifier. It accepts an expression or type name; unlike typeof, it removes top-level qualifiers and atomicity.

For const int * const, the result is const int *: pointed-to qualification remains. Deriving the type does not itself modify the object.

The operand is evaluated only if its type is variably modified. Evaluating the operand can have side effects: if p is a pointer to a variable-length array, typeof_unqual(p++) can modify p. An operand designating a bit-field is prohibited.

Examples

#include <stdio.h>

int main(void)
{
    const int source = 7;
    typeof_unqual(source) copy = source;
    copy += 1;
    printf("%d %d\n", source, copy);
    return 0;
}

Result

7 8

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources