[llvm-bugs] [Bug 52014] New: Bogus "conversion would be valid if it was derived from" note with const mismatch

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Sep 29 11:05:20 PDT 2021


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

            Bug ID: 52014
           Summary: Bogus "conversion would be valid if it was derived
                    from" note with const mismatch
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: harald at gigawatt.nl
                CC: blitzrakete at gmail.com, dgregor at apple.com,
                    erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
                    richard-llvm at metafoo.co.uk

The invalid code

  typedef struct S s;
  const s *f();
  s *g() { return f(); }

results in

  test.cc:3:17: error: cannot initialize return object of type 's *' (aka 'S
*') with an rvalue of type 'const s *' (aka 'const S *')
  s *g() { return f(); }
                  ^~~
  test.cc:1:16: note: 'S' is not defined, but forward declared here; conversion
would be valid if it was derived from 'S'
  typedef struct S s;
                 ^
  1 error generated.

The error message is correct, but the note is not. The problem here is not
whether S is derived from itself, the problem is just the const mismatch.

-- 
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/20210929/9a16accb/attachment.html>


More information about the llvm-bugs mailing list