Skip to content

Const suggestion check: an alias of a deduced parameter type keeps the suggestion not checked #250

Open

Description

@SizzleUnrlsd

Follow-up of #217 and #239 (final review, M1).

With --experimental-const-suggestion-check, a suggestion stays "not checked" when the parameter's type reaches a local through an alias of a deduced type, while the same code without the alias is checked:

int direct(int* p)
{
    decltype(p) q = p;
    return *q;
}
int aliased(int* p)
{
    using P = decltype(p);
    P q = p;
    return *q;
}
  • direct: checked in the analyzed files only.
  • aliased: not checked with Clang: the rewrite also changes the type of q (a.cpp:9).

The scope step (§5.6, D19) tells the written form from the deduced part, but it does not follow a typedef or an alias declaration whose type is itself deduced from a planned parameter (writtenForm in src/analysis/ConstSuggestionFacts.cpp), so q's type counts as written by the rewrite.

Effect: a suggestion that could be shown valid is kept as not checked. That is conservative; no verdict is wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions