Topic: VAC++ vs. Boost (language lawyers?)


Author: Ron Natalie <ron@sensor.com>
Date: 2000/11/28
Raw View

Gary Coen wrote:
>
> Is this is an issue with the VAC++ 4.2 compiler (on NT) or a syntax
> issue with the Boost library <stl_hashtable.h>? Maybe there are
> some language lawyers out there who have opinions. (You never know.)

I don't know what VAC++ is (but if it's IBM Visual Age, it has serious
problems with the concept of include files that prevent it from ever
being considered a standard compiler).

>
>      "Hashtable" cannot be declared because its name has already
>      been used.

Looks to me that the hashtable attempting to be defined is scoped
to the iterator class and should not conflict with the namespace
scope definition.  If this is is the case, then it looks like VA
also has serious defects in it's type scoping.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]






Author: Gary Coen <coens@attglobal.net>
Date: 2000/11/28
Raw View
Thanks to you and David Abrahams for pointing that out. The library
<stl_hashtable.h> that is the topic of this discussion is not a Boost
library as I had imagined. Instead, it appears in cygwin's distribution
of  gcc 2.95.2 in the sub-directory usr/include/g++-3. It's an SGI
creation, as the name would imply.

Jeremy Siek contributed a few files to the Boost 1.18.2 distribution
with a similar naming convention (e.g., stl_concept-checks.cpp). I'm
a newcomer to Boost, and I initially assumed that Boost had selected
some contributions from SGI. My mistake.

Thanks again for your insightful reply.

--Gary

Valentin Bonnard wrote:

> Gary Coen  wrote:
> > Is this is an issue with the VAC++ 4.2 compiler (on NT) or a syntax
> > issue with the Boost library <stl_hashtable.h>? Maybe there are
> > some language lawyers out there who have opinions. (You never know.)
>
> First, note that Boost has no header called stl_hashtable.h (and no has=
h
> tables at all).
>
> > (2) Then a declaration for a templated struct __hashtable_iterator
> > follows:
>
> Second, note that the use of identifiers like __hashtable_iterator
> in normal C++ code is a terrible idea and Boost never uses
> identifiers with __ in them.
>
> > (3) Next __hashtable_iterator is defined using a typedefed hashtable
> > parameterized according to the forward declaration in (1):
> >
> >      template <class Value, class Key, class HashFcn,
> >                class ExtractKey, class EqualKey, class Alloc>
> >      struct __hashtable_iterator {
> >        typedef hashtable<Value, Key, HashFcn, ExtractKey, EqualKey,
>                  ^^^^^^^^^
> >                          Alloc>
> >                hashtable;
>                  ^^^^^^^^^
> >      ...}
>
> Here, ::hashtable is used to define hashtable.
>
> Not only this is a common practice, such kind of things
> is also mandated by the standard.
>
> > On the final word in the typedef of (3), the VAC++ 4.2 compiler
> > complains as follows:
> >
> >      "Hashtable" cannot be declared because its name has already
> >      been used.
> >
> > Helpfully, the compiler identifies the previous instance of "hashtabl=
e"
> > in that typedef as the prior use of the term "hashtable" that must be
> > respected.
>
> Fix for the headers:
>
>  add explicit qualification for names used and then hidden in the
>  class where then have been redefined.
>
> Example:
>
> typedef int i;
>
> struct T {
>   typedef ::i i;
> };
>
> > GCC 2.95.2 has no trouble with Boost's <stl_hashtable.h>, but VAC++ 4=
.2
> > won't compile it.
>
> Actually egcs-2.91.66 complains too.
>
> > Does this snippet of <stl_hashtable.h> comply with the
> > standard?
>
> The code you quoted doesn't comply. (See 3.3.6/1.2)
>
> Actually I have just checked
> <URL:http://www.sgi.com/Technology/STL/stl_hashtable.h>,
> and it doesn't seem to have the problem you mention.
>
> > Which compiler performs according to the standard?
>
> All three.
>
> --
>
> Valentin Bonnard
>
> ---
> [ comp.std.c++ is moderated.  To submit articles, try just posting with=
 ]
> [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu   =
 ]
> [              --- Please see the FAQ before posting. ---              =
 ]
> [ FAQ: http://www.research.att.com/~austern/csc/faq.html               =
 ]
> [ Note that the FAQ URL has changed!  Please update your bookmarks.    =
 ]

--
=D0=CF_=E0=A1

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]






Author: Gary Coen <coens@attglobal.net>
Date: Sun, 26 Nov 2000 00:23:02 GMT
Raw View
Is this is an issue with the VAC++ 4.2 compiler (on NT) or a syntax
issue with the Boost library <stl_hashtable.h>? Maybe there are
some language lawyers out there who have opinions. (You never know.)

(1) First, Boost's <stl_hashtable.h> declares a templated class named
hashtable:

     template <class Value, class Key, class HashFcn,
                    class ExtractKey, class EqualKey, class Alloc>
     class hashtable;

(2) Then a declaration for a templated struct __hashtable_iterator
follows:

     template <class Value, class Key, class HashFcn,
               class ExtractKey, class EqualKey, class Alloc>
     struct __hashtable_iterator;

(3) Next __hashtable_iterator is defined using a typedefed hashtable
parameterized according to the forward declaration in (1):

     template <class Value, class Key, class HashFcn,
               class ExtractKey, class EqualKey, class Alloc>
     struct __hashtable_iterator {
       typedef hashtable<Value, Key, HashFcn, ExtractKey, EqualKey,
                         Alloc>
               hashtable;
     ...}

On the final word in the typedef of (3), the VAC++ 4.2 compiler
complains as follows:

     "Hashtable" cannot be declared because its name has already
     been used.

Helpfully, the compiler identifies the previous instance of "hashtable"
in that typedef as the prior use of the term "hashtable" that must be
respected.

GCC 2.95.2 has no trouble with Boost's <stl_hashtable.h>, but VAC++ 4.2
won't compile it. Does this snippet of <stl_hashtable.h> comply with the
standard? Which compiler performs according to the standard?

--Gary

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]





Author: Dean Roddey <droddey@charmedquark.com>
Date: Sun, 26 Nov 2000 01:11:49 GMT
Raw View
Well, given that VC++ is now on Version 6.0, I don't see much use in even
knowing whether 4.2 is right or not. Its so completely out of spec that its
probably a safe bet to just assume its wrong. Upgrade to V6.0 and try it and
you'll probably save yourself a lot of time.

--------------------------
Dean Roddey
The CIDLib C++ Frameworks
Charmed Quark Software
droddey@charmedquark.com
http://www.charmedquark.com

"It takes two buttocks to make friction"
    - African Proverb


"Gary Coen" <coens@attglobal.net> wrote in message
news:3A200CD2.80002A@attglobal.net...
> Is this is an issue with the VAC++ 4.2 compiler (on NT) or a syntax
> issue with the Boost library <stl_hashtable.h>? Maybe there are
> some language lawyers out there who have opinions. (You never know.)
>
> (1) First, Boost's <stl_hashtable.h> declares a templated class named
> hashtable:
>


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]





Author: Gary Coen <coens@attglobal.net>
Date: 2000/11/26
Raw View
Oops. Pardon me for being obtuse. My question concerned VAC++,
not VC++. My mistake for not being clear. VAC++ is the IBM C++
compiler. It is only related to the Microsoft product (called VC++)
inasmuch as both products compile C++ source code.

The current version of the IBM C++ compiler is 4.x (on Intel platforms)
and 5.0 on AIX.

Now, are there any language lawyers out there?

--Gary

Dean Roddey wrote:

> Well, given that VC++ is now on Version 6.0, I don't see much use in ev=
en
> knowing whether 4.2 is right or not. Its so completely out of spec that=
 its
> probably a safe bet to just assume its wrong. Upgrade to V6.0 and try i=
t and
> you'll probably save yourself a lot of time.
>
> --------------------------
> Dean Roddey
> The CIDLib C++ Frameworks
> Charmed Quark Software
> droddey@charmedquark.com
> http://www.charmedquark.com
>
> "It takes two buttocks to make friction"
>     - African Proverb
>
> "Gary Coen" <coens@attglobal.net> wrote in message
> news:3A200CD2.80002A@attglobal.net...
> > Is this is an issue with the VAC++ 4.2 compiler (on NT) or a syntax
> > issue with the Boost library <stl_hashtable.h>? Maybe there are
> > some language lawyers out there who have opinions. (You never know.)
> >
> > (1) First, Boost's <stl_hashtable.h> declares a templated class named
> > hashtable:
> >
>
> ---
> [ comp.std.c++ is moderated.  To submit articles, try just posting with=
 ]
> [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu   =
 ]
> [              --- Please see the FAQ before posting. ---              =
 ]
> [ FAQ: http://www.research.att.com/~austern/csc/faq.html               =
 ]
> [ Note that the FAQ URL has changed!  Please update your bookmarks.    =
 ]

--
=D0=CF_=E0=A1

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]






Author: Valentin.Bonnard@free.fr (Valentin Bonnard)
Date: 2000/11/27
Raw View
Gary Coen  wrote:
> Is this is an issue with the VAC++ 4.2 compiler (on NT) or a syntax
> issue with the Boost library <stl_hashtable.h>? Maybe there are
> some language lawyers out there who have opinions. (You never know.)

First, note that Boost has no header called stl_hashtable.h (and no hash
tables at all).

> (2) Then a declaration for a templated struct __hashtable_iterator
> follows:

Second, note that the use of identifiers like __hashtable_iterator
in normal C++ code is a terrible idea and Boost never uses
identifiers with __ in them.

> (3) Next __hashtable_iterator is defined using a typedefed hashtable
> parameterized according to the forward declaration in (1):
>
>      template <class Value, class Key, class HashFcn,
>                class ExtractKey, class EqualKey, class Alloc>
>      struct __hashtable_iterator {
>        typedef hashtable<Value, Key, HashFcn, ExtractKey, EqualKey,
                 ^^^^^^^^^
>                          Alloc>
>                hashtable;
                 ^^^^^^^^^
>      ...}

Here, ::hashtable is used to define hashtable.

Not only this is a common practice, such kind of things
is also mandated by the standard.

> On the final word in the typedef of (3), the VAC++ 4.2 compiler
> complains as follows:
>
>      "Hashtable" cannot be declared because its name has already
>      been used.
>
> Helpfully, the compiler identifies the previous instance of "hashtable"
> in that typedef as the prior use of the term "hashtable" that must be
> respected.

Fix for the headers:

 add explicit qualification for names used and then hidden in the
 class where then have been redefined.

Example:

typedef int i;

struct T {
  typedef ::i i;
};

> GCC 2.95.2 has no trouble with Boost's <stl_hashtable.h>, but VAC++ 4.2
> won't compile it.

Actually egcs-2.91.66 complains too.

> Does this snippet of <stl_hashtable.h> comply with the
> standard?

The code you quoted doesn't comply. (See 3.3.6/1.2)

Actually I have just checked
<URL:http://www.sgi.com/Technology/STL/stl_hashtable.h>,
and it doesn't seem to have the problem you mention.

> Which compiler performs according to the standard?

All three.

--

Valentin Bonnard

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]






Author: "David Abrahams" <abrahams@mediaone.net>
Date: 2000/11/27
Raw View
"Gary Coen" <coens@attglobal.net> wrote in message
news:3A200CD2.80002A@attglobal.net...
> Is this is an issue with the VAC++ 4.2 compiler (on NT)

Just to be clear: this is IBM's VisualAge compiler?

> or a syntax
> issue with the Boost library <stl_hashtable.h>? Maybe there are
> some language lawyers out there who have opinions. (You never know.)
>
> (1) First, Boost's <stl_hashtable.h> declares a templated class named
> hashtable:

Nope. No such beast exists in Boost, at least not yet. Please give discredit
where it is due (if at all).

> GCC 2.95.2 has no trouble with Boost's <stl_hashtable.h>, but VAC++ 4.2
> won't compile it. Does this snippet of <stl_hashtable.h> comply with the
> standard?

Yes.

> Which compiler performs according to the standard?

None, but some are close. Compilers based on recent editions of the EDG
(Edison Design Group) front-end are darned close.

-Dave


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]






Author: Bill Wade <wrwade@swbell.net>
Date: 2000/11/27
Raw View
"Gary Coen" <coens@attglobal.net> wrote<
> {
>        typedef hashtable<Value, Key, HashFcn, ExtractKey, EqualKey,
>                          Alloc>
>                hashtable;
>      ...}
>
> On the final word in the typedef of (3), the VAC++ 4.2 compiler
> complains as follows:
>
>      "Hashtable" cannot be declared because its name has already
>      been used.

I don't see any such restriction in the standard.  I can understand how a
compiler writer might find it convenient to make such a restriction.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]
[ Note that the FAQ URL has changed!  Please update your bookmarks.     ]