[llvm-bugs] [Bug 25350] New: Warn about overload resolution with forward-declared types?

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Oct 29 16:19:49 PDT 2015


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

            Bug ID: 25350
           Summary: Warn about overload resolution with forward-declared
                    types?
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: hans at chromium.org
                CC: llvm-bugs at lists.llvm.org, nicolasweber at gmx.de
    Classification: Unclassified

Consider the following:

s.h:

  struct S {};
  struct T : S {};

a.cc:

  #if X
  // Forward declarations, for speed:
  struct S;
  struct T;
  #else
  // Just include it, for clarity:
  #include "s.h"
  #endif

  void f(void*);
  void f(S*);

  void surprise(T *t) { f(t); } // Which f gets called?


Depending on the value of X, i.e. whether we're including s.h or forward
declaring S and T, the call in surprise() will be bound to a different
function.

Could we warn that overload resolution for the call to f is based on an
incomplete type?

(Inspired by an example from:
http://google.github.io/styleguide/cppguide.html#Forward_Declarations)

-- 
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/20151029/ea5f20c4/attachment.html>


More information about the llvm-bugs mailing list