[patch] fix pr15930

Rafael EspĂ­ndola rafael.espindola at gmail.com
Wed May 15 21:44:32 PDT 2013


On 15 May 2013 17:18, Richard Smith <richard at metafoo.co.uk> wrote:
> Patch looks good, but don't you need to also change all the other calls to
> QualType::getLinkageAndVisibility? In C++14 at least, a no-linkage type can
> completely leak out of a function and be used as a type of a non-type
> template parameter. For instance:
>
> inline auto f() {
>   struct S {};
>   return S();
> }
> template<decltype(f())*> struct X { X() {} };
> X<nullptr> x;
>
> Right now, this incorrectly generates @x as an internal-linkage symbol. You
> can probably observe the same bug in C++11 by passing S to a template like
> this:
>
> template<typename T> struct Outer { template<T *p> struct Inner { ... }; };

So, I am trying to create a full c++11 testcase. The closest I have so far is

template <typename T>
struct foo {
  template <T *P> static void f() {
  }
  static void *g() {
    static T x;
    return (void*)f<&x>;
  }
};

inline void *f() {
  struct S {
  };
  return foo<S>::g();
}

but this fails to compile with

address of overloaded function 'f' does not match required type 'void'

which I assume is because I am trying to use an object without linkage
in a non type template argument. Is that supposed to work?

Cheers,
Rafael



More information about the cfe-commits mailing list