-
Couldn't load subscription status.
- Fork 15k
Closed as duplicate of#73232
Closed as duplicate of#73232
Copy link
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"constexprAnything related to constant evaluationAnything related to constant evaluationdiverges-from:gccDoes the clang frontend diverge from gcc on this issueDoes the clang frontend diverge from gcc on this issuediverges-from:msvcDoes the clang frontend diverge from msvc on this issueDoes the clang frontend diverge from msvc on this issueduplicateResolved as duplicateResolved as duplicate
Description
The following code
class X
{
public:
constexpr int f( int x ) const
{
return g( x );
}
private:
template<class T>
constexpr T g( T x ) const
{
return x;
}
};
constexpr int x = X().f( 1 );
is rejected by Clang trunk (and all previous versions AFAICS) with
<source>:7:16: note: undefined function 'g<int>' cannot be used in a constant expression
7 | return g( x );
| ^
and in order to fix that, the definition of g needs to be moved above that of f.
But I don't think this order dependency is required by the standard, and other compilers accept the code.
Metadata
Metadata
Assignees
Labels
clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"constexprAnything related to constant evaluationAnything related to constant evaluationdiverges-from:gccDoes the clang frontend diverge from gcc on this issueDoes the clang frontend diverge from gcc on this issuediverges-from:msvcDoes the clang frontend diverge from msvc on this issueDoes the clang frontend diverge from msvc on this issueduplicateResolved as duplicateResolved as duplicate