[PATCH] D30170: Function definition may have uninstantiated body

Serge Pavlov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 28 10:51:54 PST 2018


sepavloff added a comment.

The issue is still observed in trunk. Other compilers process the tests correctly (checked using https://godbolt.org/). For instance, the code:

  template<typename T> struct C20 {
  friend void func_20() {} // expected-note{{previous definition is here}}
  };
  C20<int> c20i;
  void func_20() {} // expected-error{{redefinition of 'func_20'}}

is rejected by gcc 7.3:

  <source>: In function 'void func_20()':
  <source>:5:6: error: redefinition of 'void func_20()'
   void func_20() {} // expected-error{{redefinition of 'func_20'}}
        ^~~~~~~
  <source>:2:13: note: 'void func_20()' previously declared here
   friend void func_20() {} // expected-note{{previous definition is here}}
               ^~~~~~~
  Compiler returned: 1

by ICC 18:

  <source>(5): error: function "func_20" has already been defined
    void func_20() {} // expected-error{{redefinition of 'func_20'}}
         ^
  compilation aborted for <source> (code 2)
  Compiler returned: 2

and by MSVC 19 2017:

  <source>(5): error C2084: function 'void C20<int>::func_20(void)' already has a body
  <source>(2): note: see previous definition of 'func_20'
  Microsoft (R) C/C++ Optimizing Compiler Version 19.10.25017 for x64
  Copyright (C) Microsoft Corporation.  All rights reserved.
  Compiler returned: 2


https://reviews.llvm.org/D30170





More information about the cfe-commits mailing list