Skip to content

RULE-5-10-1 reports false positives on compiler-predefined function identifiers (__func__, __FUNCTION__, __PRETTY_FUNCTION__) #1170

Description

@castler

Affected rules

  • RULE-5-10-1

Description

The query flags the compiler-predefined function identifiers __func__, __FUNCTION__ and __PRETTY_FUNCTION__ for "contains double underscores" / "starts with underscore". These are not user-defined
identifiers
__func__ is mandated by the C++ standard ([dcl.fct.def.general]) and FUNCTION/PRETTY_FUNCTION` are GCC/Clang extensions — so RULE-5-10-1 (which is scoped to user-defined identifiers) should not report them.

Example

The compiler synthesizes one such static const char __PRETTY_FUNCTION__[] = "..." inside every function that
references it. These references very often come from assert-style macros (e.g. an ASSERT_MESSAGE(...) macro that embeds __PRETTY_FUNCTION__), so the synthesized variable is attributed to each macro invocation site in user
code. The result is one false positive per macro usage.

e.g. https://github.com/eclipse-score/baselibs/blob/ebe13d853e87ce067507212ff736af14b7941f6d/score/language/futurecpp/include/score/private/assert/assert_impl.hpp#L50

Impact

In score/communication this causes ~79% of all RULE-5-10-1 findings (228)

Metadata

Metadata

Assignees

No one assigned

    Labels

    false positive/false negativeAn issue related to observed false positives or false negatives.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions