Bug 21426 - anonymous enums vs. templates
Summary: anonymous enums vs. templates
Status: RESOLVED DUPLICATE of bug 19404
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-05-06 20:11 UTC by Aaron M. Ucko
Modified: 2005-07-23 22:49 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Aaron M. Ucko 2005-05-06 20:11:28 UTC
If one instance of an overloaded function or operator is generic, I cannot
supply a member of an anonymous enum to that function or operator, even if I
wouldn't be calling the generic instance anyway.  As an example of the problem,
attempting to compile the simplified code

  class S;
  template <typename T> S& operator<< (S&, const T&);

  enum { x };
  static const int xx = 1 << x;

with G++ 4.0.0 fails with the error

anonenum.cc:5: error: '<anonymous enum>' is/uses anonymous type
anonenum.cc:5: error:   trying to instantiate 'template<class T> S&
operator<<(S&, const T&)'

This is a regression over previous versions, which have no problem with such
code.  (Neither do other vendors' compilers.)

It is obviously trivial to work around the bug by naming the enum, but I believe
I shouldn't need to.
Comment 1 Andrew Pinski 2005-05-06 20:16:41 UTC
The code is invalid, see PR 19404 and PR 20589

*** This bug has been marked as a duplicate of 19404 ***