[llvm-bugs] [Bug 40383] New: Broken incorrect fix-it for -Wc++11-narrowing

via llvm-bugs llvm-bugs at lists.llvm.org
Sun Jan 20 00:55:36 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=40383

            Bug ID: 40383
           Summary: Broken incorrect fix-it for -Wc++11-narrowing
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: lebedev.ri at gmail.com
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

https://godbolt.org/z/DkP1ns

struct S {
    using value_type = char;
    value_type k;
    S (value_type k_) : k(k_){};
};

S test(int i) {
    return {i};
}

<source>:8:13: error: non-constant-expression cannot be narrowed from type
'int' to 'S::value_type' (aka 'char') in initializer list [-Wc++11-narrowing]

    return {i};

            ^

<source>:8:13: note: insert an explicit cast to silence this issue

    return {i};

            ^

            static_cast<value_type>( )

1 error generated.

Compiler returned: 1


static_cast<value_type>( )  <- that is clearly wrong.
It should be something like static_cast<S::value_type>( )

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190120/8854056b/attachment.html>


More information about the llvm-bugs mailing list