Skip to content

[Clang] Add diagnostic to flag using "%P" specifier with Objective-C pointers #89968

Closed
@jaredgrubb

Description

@jaredgrubb

Darwin has an extension on the printf format-specifiers for "%P", which dumps the bytes at a pointer (in contrast to "%p" which dumps a pointer's value itself) and is allowed in "OS Log" contexts.

It's easy to misuse this, for example:

NSUUID *uuid = ...;
os_log(..., "%{uuid_t}.16P", uuid);

This dumps the ObjC class data (eg, the is-a pointer) -- not the UUID represented by the object.

It'd be nice if the compiler had a warning that could flag this misuse, which seems to always (IMO) be a bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerenhancementImproving things as opposed to bug fixing, e.g. new or missing featureobjective-c

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions