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

            Bug ID: 44558
           Summary: Nodiscard warning diagnosed twice when called in a
                    template:
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++
          Assignee: unassignedclangb...@nondot.org
          Reporter: erich.ke...@intel.com
                CC: blitzrak...@gmail.com, dgre...@apple.com,
                    erik.pilking...@gmail.com, llvm-bugs@lists.llvm.org,
                    richard-l...@metafoo.co.uk

https://godbolt.org/z/LesWP4

[[nodiscard]] int* bar();

template<typename T>
void foo() {
    bar();
}

void baz() {
    foo<int>();
}

<source>:7:5: warning: ignoring return value of function declared with
'nodiscard' attribute [-Wunused-result]

    bar();

    ^~~

<source>:7:5: warning: ignoring return value of function declared with
'nodiscard' attribute [-Wunused-result]

    bar();

    ^~~

<source>:11:5: note: in instantiation of function template specialization
'foo<int>' requested here

    foo<int>();


The warning should likely only happen 1x, but we end up diagnosing it 2x.  We
suppress 'errors' by marking the template invalid (and thus uncallable), but
don't do so with warnings.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to