December 09, 2002
namespace ns1
{
struct A
{
  static int value;
};

int A::value = 0;
}

namespace ns2
{
struct A
{
  int f()
  {
    return ns1::A::value;
    // Error: 'A' must be a public base class of 'A'
  }
};
}

int main()
{
  ns2::A a;

  return a.f();
}


bye, Christof

-- 
http://cmeerw.org                                 JID: cmeerw@jabber.at mailto cmeerw at web.de

...and what have you contributed to the Net?
December 09, 2002
In article <at0k4t$hb5$1@digitaldaemon.com>, Christof Meerwald says...
>
>namespace ns1
>{
>template<class T>
>struct A
>{
>  A() { }
>  // Error: namespace 'ns2' does not enclose member '?0' of namespace 'ns1'

This is a really nasty one that tends to cause protection fault when compiled if the code base is large enoough.

Richard


December 09, 2002
In article <at0k4t$hb5$1@digitaldaemon.com>, Christof Meerwald says...
>
>namespace ns1
>{
>template<class T>
>struct A
>{
>  A() { }
>  // Error: namespace 'ns2' does not enclose member '?0' of namespace 'ns1'

Ok, after a retest, the code provided in Christof's test case causes a protection fault with .8 - as an aside, the dll version of the compiler is fine.

smake produced -> SC -cpp -J -mn -C -WA -S -3 -a8 -c -gf -D_CONSOLE=1 -otest.obj test.cpp

Richard


December 11, 2002
namespace ns
{
template<class T>
struct A
{ };

typedef A<char> B;
}

using ns::B;

struct C
  : public B
  // Error: undefined identifier 'B'
{ };


int main()
{
  C c;

  return 0;
}


bye, Christof

-- 
http://cmeerw.org                                 JID: cmeerw@jabber.at mailto cmeerw at web.de

...and what have you contributed to the Net?
December 11, 2002
namespace ns
{
struct A
{
  void f();
};

struct B
{ };
}

void ns::A::f()
{
  B b;
  // Error: undefined identifier 'B'
}


int main()
{
  ns::A a;

  return 0;
}


(see 3.4.1 Unqualified name lookup [basic.lookup.unqual], paragraph 8, of
the C++ Standard)


bye, Christof

-- 
http://cmeerw.org                                 JID: cmeerw@jabber.at mailto cmeerw at web.de

...and what have you contributed to the Net?
December 15, 2002
#include <stdio.h>

struct A
{
  friend int f(int i)
  {
    return 1;
  }
};

int f(long i)
{
  return 0;
}


int main()
{
  printf("%d\n", f(0));
}


AFAIK, f(long) should be invoked and not f(int). See 7.3.1.2 Namespace
member definitions [namespace.memdef], paragraph 3, of the C++ standard.


bye, Christof

-- 
http://cmeerw.org                                 JID: cmeerw@jabber.at mailto cmeerw at web.de

...and what have you contributed to the Net?
December 15, 2002
Ah, no rest for the wicked <g>.

"Christof Meerwald" <cmeerw@web.de> wrote in message news:atgjkb$l63$1@digitaldaemon.com...
> #include <stdio.h>
>
> struct A
> {
>   friend int f(int i)
>   {
>     return 1;
>   }
> };
>
> int f(long i)
> {
>   return 0;
> }
>
>
> int main()
> {
>   printf("%d\n", f(0));
> }
>
>
> AFAIK, f(long) should be invoked and not f(int). See 7.3.1.2 Namespace
> member definitions [namespace.memdef], paragraph 3, of the C++ standard.
>
>
> bye, Christof
>
> --
> http://cmeerw.org                                 JID: cmeerw@jabber.at mailto cmeerw at web.de
>
> ...and what have you contributed to the Net?


December 15, 2002
Not sure if Christof posted this yet..

namespace one {

template<class T>
struct Types {
typedef int Int;
};

}

template<class T,
class  U = one::Types<int>::Int>
// Error: : no type for argument 'Int'
// Internal error: struct 2797

struct Values
{
typedef U type;
};

void main() {
typedef Values<int>::type def;
}

I tried to find chapter and verse for this but could only find 14.6.4 Dependent name resolution.. and I'm not even sure it really applies. Man, Christof is really brilliant. How did he get so smart?

Richard


December 16, 2002
namespace ns
{
struct B
{ };

struct A
{
  A(B b);
};
}

ns::A::A(B b)
// Error: ')' expected to close function parameter list with
{
}


int main()
{
  ns::B b;
  ns::A a(b);

  return 0;
}


bye, Christof

-- 
http://cmeerw.org                                 JID: cmeerw@jabber.at mailto cmeerw at web.de

December 17, 2002
I believe DMC++ is behaving correctly here. f(int i) is not declared in a namespace, but in a non-local class, which according to 7.3.1.2-3 will become "a member of the innermost enclosing namespace", which in this instance is the global namespace. Hence, it should be found via normal overload rules.

"Christof Meerwald" <cmeerw@web.de> wrote in message news:atgjkb$l63$1@digitaldaemon.com...
> #include <stdio.h>
>
> struct A
> {
>   friend int f(int i)
>   {
>     return 1;
>   }
> };
>
> int f(long i)
> {
>   return 0;
> }
>
>
> int main()
> {
>   printf("%d\n", f(0));
> }
>
>
> AFAIK, f(long) should be invoked and not f(int). See 7.3.1.2 Namespace
> member definitions [namespace.memdef], paragraph 3, of the C++ standard.
>
>
> bye, Christof
>
> --
> http://cmeerw.org                                 JID: cmeerw@jabber.at mailto cmeerw at web.de
>
> ...and what have you contributed to the Net?