c++/8338: Koenig lookup doesn't work for enum

dv@vollmann.ch dv@vollmann.ch
Thu Oct 24 07:06:00 GMT 2002


>Number:         8338
>Category:       c++
>Synopsis:       Koenig lookup doesn't find enum value in special case
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Thu Oct 24 07:06:02 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Detlef Vollmann
>Release:        3.3 20021023 (experimental)
>Organization:
vollmann engineering gmbh
>Environment:
System: Linux dwarf 2.4.3-XFS #7 Mon Aug 6 18:43:20 CEST 2001 i686 unknown
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: /pdsrc/gcc/cvs/gcc/configure --program-suffix=-test --prefix=/local/gcc-test --enable-shared --enable-threads=posix --enable-version-specific-runtime-libs --enable-languages=c,c++
>Description:
	See attached code.
	I consider the code as legal, though Alias is still an incomplete type.
	That this is a lookup problem can be seen when the initialiser 'max'
	is fully specified as 'N1::max'.
>How-To-Repeat:
	See attached code.
>Fix:
	

// Problematic code:
namespace N1
{
enum E { max = 5 };
} // N1

namespace N2
{
template <class EnumType, class OtherType>
class A
{
public:
    int f(int i) { return table[i]; }
private:
    static const EnumType size = max;
    int table[size];
};

template <class T>
struct B
{
    // empty
};

} // N2

namespace N1
{
struct C;
typedef N2::B<C> Alias;

struct C
{
    N2::A<E, Alias> a;
};

} // N1

using namespace N1;
using namespace N2;

int main()
{
    C c;

    return c.a.f(3);
}

>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the Gcc-prs mailing list