Issue 180816
Summary Clang accepts non-inline definition after inline friend declaration
Labels clang
Assignees
Reporter vrukesh
    **What code / commands /steps will reproduce the problem?**
Compile the below sample code for standard C++17.
`
struct Name {
    friend inline int bar(Name);
};

int bar(Name) { return 0; }

int main() {
    Name name;
    return bar(name);
}
`

Godbolt compile explorer link: https://godbolt.org/z/P7MPd9aoo


**What is the expected result?**
As per C++17 standard, the above code should be ill-formed; the compiler should issue at least a diagnostic because the function was declared inline and later declared/defined without `inline`.

In C++17 standard ISO/IEC 14882:2017 section 10.1.6 [dcl.inline]
_The inline specifier shall not appear on a block scope declaration.94 If the inline specifier is used in a friend function declaration, that declaration shall be a definition or the function shall have previously been declared inline._

**What happens instead?**
Compilation is successful without any compiler warning or error.

This should be fixed. There must be diagnostic because the definition lacks the required `inline` specifier after an earlier `inline` declaration.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to