Skip to content

-Wdangling-gsl only diagnoses first template argument #142801

Open
@DKLoehr

Description

@DKLoehr

We just ran into a bug where we have a gsl::Owner type which holds two values. We found that the -Wdangling-gsl warning correctly detects unsafe conversions such as string -> string_view, but only for the type which is listed first in the template arguments.

Simplified example: https://godbolt.org/z/Y56eWv74Y

Walking through the code, it seems that this is because this line only checks the first template argument, rather than all of them. Is there a reason why? Intuitively, it seems that we should be checking if any of the types are pointer-like. Does that introduce false positives?

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerfalse-negative

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions