Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang uses the regparm attribute when deciding templace specializations #11107

Closed
llvmbot opened this issue Aug 24, 2011 · 3 comments
Closed
Labels
bugzilla Issues migrated from bugzilla c++ invalid Resolved as invalid, i.e. not a bug

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Aug 24, 2011

Bugzilla Link 10735
Resolution INVALID
Resolved on Aug 24, 2011 16:18
Version unspecified
OS Linux
Reporter LLVM Bugzilla Contributor
CC @DougGregor

Extended Description

Clang rejects and gcc accepts the following code:

template struct nsRunnableMethodTraits {
};
//template struct nsRunnableMethodTraits<void attribute ((regparm (0))) (C::)()> {
template struct nsRunnableMethodTraits<void (C::
)()> {
typedef int base_type;
};
template typename nsRunnableMethodTraits::base_type* NS_NewRunnableMethod(Method method) ;

struct C1 {
virtual void attribute ((regparm (0))) FinishStream(void) {
NS_NewRunnableMethod( &C1::FinishStream);
}
};

Changing which line make clang accept the code.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Aug 24, 2011

Changing which line is commented...

@llvmbot
Copy link
Collaborator Author

llvmbot commented Aug 24, 2011

The analogous case is that clang accepts

template struct nsRunnableMethodTraits;

template struct nsRunnableMethodTraits<void (C::)()> {
typedef int base_type;
};
template struct nsRunnableMethodTraits<void attribute ((regparm (0))) (C::
)()> {
typedef int base_type;
};

and g++ rejects it:

nsUrlClassifierProxies.ii:7:27: error: redefinition of ‘struct nsRunnableMethodTraits<void (C::)()>’
nsUrlClassifierProxies.ii:3:27: error: previous definition of ‘struct nsRunnableMethodTraits<void (C::
)()>’

@DougGregor
Copy link
Contributor

Clang is behaving correctly here. A regparm-attributed member function pointer type is distinct from a non-regparm-attributed member function pointer type, so they'll have different template specializations. GCC's behavior appears to be inconsistent here, because the types are considered equivalent for the purposes of matching template arguments, so the regparm attribute associated with the first instantiation is the one that "sticks", even if subsequent instantiations don't have the regparm attribute.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla c++ invalid Resolved as invalid, i.e. not a bug
Projects
None yet
Development

No branches or pull requests

2 participants