Topic: RFD: C++ Compiler/Library Conformance Issues
Author: kanze@gabi-soft.de
Date: 2000/07/04 Raw View
Martin Sebor <marts@att.net> writes:
|> kanze@gabi-soft.de wrote:
|> ....
|> > Section 17.4.4.1, paragraph 1: "A C++ header may include other C++
|> > headers." I think this is a difference with respect to C; although=
the
|> > C standard doesn't explicitly forbid including other headers, it do=
esn't
|> > authorize the header to define symbols other than those generally
|> > reserved or those "listed in its associated subclause".
|> > This raises an interesting question. Is the following program requ=
ired
|> > to work?
|> > #define NDEBUG
|> > #include <cassert>
|> > #undef NDEBUG
|> > #include <iostream>
|> > int
|> > main()
|> > {
|> > assert( 0 =3D=3D 1 ) ;
|> > std::cout << "works\n" ;
|> > return 0 ;
|> > }
|> > If <iostream> includes <cassert>, it won't.
|> I think whether it works or not will probably depend on the quality o=
f
|> implementation.
In practice, I think it will generally work, because the implementations
of <iostream> don't include cassert. Whether it is required to work,
however, depends on the interpretation of the quoted phrase. If
<cassert> is a C++ header, in the sense of the quoted phrase (and I
think it is), then it is not guaranteed to work.
--=20
James Kanze mailto:kanze@gabi-soft.de
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
Ziegelh=FCttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: John_Maddock@compuserve.com (John Maddock)
Date: 2000/06/25 Raw View
OK here is at least some of the issues that have bitten me:
1) Run time problems: these are the hardest of all to track down, and
may take the form of either compiler or library bugs, some of those
that have hit me include:
* buggy destructor cleanup on thrown exception (some versions of the
Borland compilers)
* Bad assembly generation when combining certain headers
(gcc2.95/mingw32 port).
* Apparently buggy std::getline implementations (C++ Builder 5 and
VC6).
2) compile time problems (and I don't mean features that are
documented as not supported):
* Internal compiler errors (mostly VC6)
* Template friend functions (most current compilers)
* Wide character support - I don't think I've yet found a compiler
that even bothers to define WCHAR_MAX, and that's just the start....
* non-standard <cheader> versions of the C standard headers - frankly
these are vertually unuseable (declarations not in namespace std,
headers just plain missing, declarations as macros instead of
inlines...)
3) unsupport features:
* export (obviously)
* template friends
* Koenig lookup (can't find associated operators without it)
* partial ordering of template functions (just try overloading
template functions without this)
* covariant returns
* etc etc etc....
Hope this helps... :-)
John Maddock
http://ourworld.compuserve.com/homepages/John_Maddock/
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "David Abrahams" <abrahams@mediaone.net>
Date: 2000/06/25 Raw View
<llewelly@brownie.frogger.foobar.snot> wrote in message
news:m2snu5assk.fsf@brownie.frogger.foobar.snot...
> "David Abrahams" <abrahams@mediaone.net> writes:
> I have not used msvc++ (well, not in over 2 years), but I would claim
> that for most modern c++ compilers, the bugs cannot be easily
> summarized. In general, one cannot simply say 'Compiler X does not
> support feature Y'. (If one does, one often finds out one was thinking
> of compiler X as it was a few years ago.)
You have captured my point exactly. Msvc++ just happens to be (much) worse
in this regard than the other compilers I use. I was really trying to
express frustration with this conformance question. It's a good question,
but answering it usefully without dealing with the bugs issue is probably
hopeless. That's probably not as true on the library side, of course.
-Dave
P.S. for balance, here's a GCC 2.95.2 bug which bites me a lot: it gets
confused about Koenig lookup when friend functions are written inline in a
namespace:
namespace foo {
// won't work unless addable is in the global namespace.
template <class T>
struct addable
{
friend T operator+(T x, T y) { return x += y; }
};
struct Long : addable<Long>
{
Long& operator+=(const Long& rhs);
long value;
};
}
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: kanze@gabi-soft.de
Date: 2000/06/26 Raw View
James Kuyper <kuyper@wizard.net> writes:
|> If portability to non-standard implementations is an issue, you must
|> also ban <iostream.h>. It worked in many different incompatible ways
|> under different pre-standard implementations. Your only choice, if
|> your code must be compatible with non-standard implementations, is
|> to define your own string library, that doesn't use reserved names,
|> and package it with your code.
Not in the real world. There were (and certainly still are) variations
in <iostream.h>, but there was a sufficiently large subset that was
pretty universel, and could be used without problem.
There's an old saying, which says that the only portable program is one
that has been ported. Strictly speaking, no program can be guaranteed
portable to a machine to which it hasn't been ported. Even if it is
100% standard conform, it might just trigger some exotic error in a
"conforming" compiler. Normally, writing conforming code is an
effective means of increasing the probability that the program will
port, not of guaranteeing it 100%. With C++ today, however, writing
100% conforming code is almost a way of guaranteeing that your program
won't port. In particular, a program which uses <iostream.h> will have
a higher probability of being portable to the widest range of compilers.
|> > |> My issues, or at least the ones which occur to me now, are
|> > |> - Inability to catch exceptions thrown by initialisers to a
|> > |> constructor.
|> > There's no way to do this in portable code.
|> See section 15p3, describing and demonstrating the use
|> function-try-blocks in a constructor, to catch exceptions generated
|> by the initializers. That code is supposed to be portable to any
|> conforming implementation. Since this thread is about conformance
|> issues, that is an entirely legitimate complaint, even (or perhaps
|> especially) if this is an extremely common form of non-conformance.
OK. I've lost the initial context, but yes, it is a bother not to be
able to do it (portably, at least), and the standard says we *should* be
able to do it. If that was the context, then I agree.
[...]
|> You're missing the point. Look at the title of this thread. The
|> overloaded abs() function is supposed to be portably available. The
|> fact that it isn't is a legitimate conformance issue.
I think I was missing the point. I missed the initial posting in the
thread, and since the posting talked about portability, I proposed
portability solutions. You're perfectly right that we shouldn't need
these solutions, and given from what I've since seen of the thread, I
understand the posters point.
--=20
James Kanze mailto:kanze@gabi-soft.de
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
Ziegelh=FCttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: kanze@gabi-soft.de
Date: 2000/06/26 Raw View
cmd@gmrc.gecm.com (Chris Dearlove) writes:
|> kanze@gabi-soft.de wrote:
|> : cmd@gmrc.gecm.com (Chris Dearlove) writes:
|> : If portability is one of the project requirements, such
|> : guidelines should ban <iostream> (and a host of other new features).
|> This I think misses the point of this thread, which is that if more
|> compilers were more standard compliant then we could Do The Right
|> Thing (which banning <iostream> is definitely not) and be portable.
|> : |> - Inability to catch exceptions thrown by initialisers to a
|> : |> constructor.
|> : There's no way to do this in portable code.
|> But there is in the standard (reference not to hand, Stroustrup 3rd e=
d.
|> 14.4.6.1) and that is the point of his thread.
Agreed. I hadn't seen the beginning of the thread. In fact, the fact
that I still have to use <iostream.h> and above all <strstream.h> in
portable code is probably what I miss most with regards to standards
conformance.
|> : |> - Polluted headers (the principal problem being that of acciden=
tally
|> : |> omitting a standard required header because the code still
|> : |> compiles but won't elsewhere of course).
|> : The standard won't help you here. A standard header is allowed
|> (but not : required) to include any other standard headers it wants.
|> Have you got a standard reference for this. I believe this is not the
|> case in C, is C++ that different?
Section 17.4.4.1, paragraph 1: "A C++ header may include other C++
headers." I think this is a difference with respect to C; although the
C standard doesn't explicitly forbid including other headers, it doesn't
authorize the header to define symbols other than those generally
reserved or those "listed in its associated subclause".
This raises an interesting question. Is the following program required
to work?
#define NDEBUG
#include <cassert>
#undef NDEBUG
#include <iostream>
int
main()
{
assert( 0 =3D=3D 1 ) ;
std::cout << "works\n" ;
return 0 ;
}
If <iostream> includes <cassert>, it won't.
--=20
James Kanze mailto:kanze@gabi-soft.de
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
Ziegelh=FCttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: kanze@gabi-soft.de
Date: 2000/06/26 Raw View
"Sam Lindley" <sam@redsnapper.net> writes:
|> <kanze@gabi-soft.de> wrote in message news:86g0q5q4dq.fsf@gabi-soft.d=
e...
|> "Sebastian Moleski" <sebmol@gmx.net> writes:
|> [...]
|> > I know. On the other hand, standard conforming code doesn't work w=
ith
|> > many compilers, starting with g++. You have the choice: standard
|> > conforming, or portable working code.
|> > In the end, today, the easiest way to write portable code is just t=
o
|> > choose a single, retargeted compiler, and write to it. The one I'm
|> > familiar with is g++ 2.95.2: very strong in templates, but decidely
|> > mixed in the library. So my code contains <strstream.h> but
|> > <vector>:-). I'd obviously prefer everything standard, but not as =
much
|> > as I prefer working code.
|> Why not use SGIs implementation?
|> (http://www.sgi.com/Technology/STL/standard_library.html)
Because I have other things to do than building up a development system
by hand. I telecharged g++ 2.95.2 and installed it in under 5 minutes
of my time. I know that the full system has been tested by Cygnus, and
is fully supported by a top rate team. I know that if I have a problem,
I don't have to try and figure out if it is the library, or the compiler
-- there is exactly one address to send bug reports to.
I'm certain that some time in the future (near or far, I don't know),
g++ will integrate a new library. At that point, I presume that there
will be a number of pre-releases, and bug fixes. And that only
following that experimental phase, the new version will appear as the
"standard" release. And then, I'll download it, and use it.
Until then, I'd rather deal with old libraries than with instability.
--=20
James Kanze mailto:kanze@gabi-soft.de
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
Ziegelh=FCttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: James Kuyper <kuyper@wizard.net>
Date: 2000/06/26 Raw View
kanze@gabi-soft.de wrote:
>
> comeau@panix.com (Greg Comeau) writes:
....
> Today, there is a greater probability that your code will work with
> different compilers if you include <iostream.h> than if you include
> <iostream>. The opposite should be true, but in practice, it's not.
In the context of a discussion titled "... Conformance Issues", "should
be" is more relevant than "in practice".
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Martin Sebor <marts@att.net>
Date: 2000/06/26 Raw View
kanze@gabi-soft.de wrote:
>=20
....
> Section 17.4.4.1, paragraph 1: "A C++ header may include other C++
> headers." I think this is a difference with respect to C; although the
> C standard doesn't explicitly forbid including other headers, it doesn'=
t
> authorize the header to define symbols other than those generally
> reserved or those "listed in its associated subclause".
>=20
> This raises an interesting question. Is the following program required
> to work?
>=20
> #define NDEBUG
> #include <cassert>
> #undef NDEBUG
> #include <iostream>
>=20
> int
> main()
> {
> assert( 0 =3D=3D 1 ) ;
> std::cout << "works\n" ;
> return 0 ;
> }
>=20
> If <iostream> includes <cassert>, it won't.
I think whether it works or not will probably depend on the quality of
implementation. While the footnote in 17.4.2.1 says that the behavior of
<assert.h> and <cassert> wrt. to NDEBUG is the same as in the Standard C
library, I believe the C++ standard should specifically address this
issue.
Martin
>=20
> --
> James Kanze mailto:kanze@gabi-soft.de
> Conseils en informatique orient=E9e objet/
> Beratung in objektorientierter Datenverarbeitung
> Ziegelh=FCttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627
>=20
> ---
> [ 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://reality.sgi.com/austern_mti/std-c++/faq.html =
]
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Martin Sebor <marts@att.net>
Date: 2000/06/26 Raw View
kanze@gabi-soft.de wrote:
>
> Jim Hyslop <jim.hyslop@leitch.com> writes:
>
> |> F'rinstance, someone mentioned the scope of a variable declared in a
> |> for-init-statement - is that really important, or just an annoyance?
> |> IMO it's an annoyance, because it's something you can work around
> |> quite easily.
>
> Right. In practice, in my code, if it works with the new scope, it will
> work with the old, since my functions are all extremely small, and I
> can't think of any where I have multiple for loops.
While it may be just an annoyance to some, it is an excellent example
where a modern compiler still doesn't follow a simple rule required by
the standard. Many (most?) compilers do allow the old rule for backwards
compatibility but provide a switch when a strict conformance is required
(or the other way around). MSVC also has an option that lets you turn on
the new rule. Unfortunately flipping it disables otherwise useful
extensions that even Microsoft's own code depends on, so for many it's
not a viable alternative. What it means in practice is that it's
unnecessarily hard to port conforming code to that compiler (even if the
workaround is as simple as -D"for=if (0) ; else for").
Martin
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: herwin@gmu.edu (Harry Erwin)
Date: 2000/06/27 Raw View
<llewelly@brownie.frogger.foobar.snot> wrote:
>
> The fact that almost no-one has time to become familiar with more than
> one compiler is an additional problem.
>
When you teach, you are forced to gain that familiarity. I require all
programs to eventually compile under gcc 2.9.5 on the school UNIX
cluster, but the students still insist on developing the code elsewhere
(for excellent reasons) and then come to me for help. To retain my
sanity--I have to keep multiple compilers around anyway--I simply give a
red card to certain compilers (e.g., MSVC++ 6.0) whose deficiencies are
so numerous that I don't want to go there.
--
Harry Erwin, PhD, <herwin@gmu.edu>, Bat Researcher, Senior SW Analyst
and Security Engineer, and Adjunct Professor of Computer Science,
George Mason University.
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Mitch Adler <mitch@intelligentparadigm.com>
Date: 2000/06/28 Raw View
In article <20000623.17525046@jb-11116.stardiv.de>,
joerg.barfurth@attglobal.net wrote:
>The error message is misleading, but you might try this without
>'template<>' on the member definition.
>What does yout compiler say then ?
Quite!
It works without the template<> prefixes.
OK, so I again refine my report:
Some compilers don't support template<> when used for out of line
template definitions.
Phew.
Thanks J rg, for your persistence in showing me the true source of my
headache.
Mitch
------------------------------------------------------------------------
Mitch Adler "There are people in the world who
Intelligent Paradigm do not love their fellow human beings,
Mitch@mitch.org and I hate people like that."
Mitch@IntelligentParadigm.com - Tom Lehrer
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: James Kuyper <kuyper@wizard.net>
Date: 2000/06/20 Raw View
Sebastian Moleski wrote:
....
> It might work but it's not standard. If the following code compiles,
> the compiler cannot be called compliant:
>
> #include <iostream.h>
>
> int main() {
> cout << "Hello, World!" << endl;
> }
False. A conforming implementation is almost never required to reject
any code. The standard often requires at least one diagnostic. However,
the only case I can remember offhand where it prohibits successful
translation is for code that contains a #error directive that survives
conditional compilation.
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "David Abrahams" <abrahams@mediaone.net>
Date: 2000/06/20 Raw View
"Scott Meyers" <smeyers@aristeia.com> wrote in message
news:MPG.13b75ee032fae4f39896fd@news.supernews.com...
> MSVC offers member templates, though my understanding is that they have
> their limitations.
Ugh! Let me just go out on a limb here and say that the non-conformance
issues with MSVC are too gnarly and numerous to list properly. It isn't so
much that any one particular feature is missing (well, partial
specialization is a big one), but that there are so many $&#*! bugs in the
compiler it's almost impossible to predict what will work in any given
situation. Often I don't find a way to name these bugs because they aren't
easily reduced to a simple test case - I just find a workaround and move on.
If you're really going to deal with non-conformance, you *have to* deal with
out-and-out compiler bugs, which are much harder to deal with than something
which is *doucumented* somewhere as non-conforming in a particular way.
So what if MSVC supports member templates if it doesn't support them fully?
Eventually you find out that you can't write object->member_function<Type>()
*after* you've already checked your code with a more competent compiler!
Eventually you find out that they only work if you declare them in the class
body. Maybe it's better to just assume they don't work!
<rant off>
Actually, I use member templates in MSVC, but it's incredibly capricious and
frustrating ;)
-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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Alain Miniussi <alainm@cup.hp.com>
Date: 2000/06/21 Raw View
Sebastian Moleski wrote:
>
> <kanze@gabi-soft.de>:
> | "Garth A. Dickie" <Garth_Dickie@avid.com> writes:
> |> 1. New-style header names, with the standard library in namespace
> std.
> |
> |> When I write code which is intended to be portable between
> |> compilers, and I want to use the C++ standard library, I would
> like
> |> to use the new style header names. This is particularly important
> |> for <iostream> and <sstream>, where the old header names provide
> |> different functionality.
> |> When I have to deal with a mixture of behavior in the compilers, I
> end
> |> up with a mess of #ifdef stuff, and no namespaces.
> |
> |I just use the old names: <iostream.h>. I've yet to encounter a
> |compiler where this didn't work.
>
> It might work but it's not standard. If the following code compiles,
> the compiler cannot be called compliant:
>
> #include <iostream.h>
>
> int main() {
> cout << "Hello, World!" << endl;
> }
Why ? I don't think the standard does specify what's in <iostream.h>
anyway.
> |> 2. Non-inline template definitions.
> |
> |> I want to have the linker instantiate templates whose
> implementation
> |> is separate from their declaration. This is the only way to
> |> break #include dependencies. The code which makes use of a
> template
> |> should not have to include all of the interfaces used by the
> |> implementation of the template.
> |
> |> Of the compilers with which I have experience, SGI's compiler does
> this,
> |> while the Metrowerks and MSVC++ compilers do not.
> |
> | And I'm willing to bet that in this regard, it's VC++ which is
> conform,
> | and NOT SGI.
>
> Why? Do you think it is right that compilers require template
> definitions to be in header files?
He did not wrote "right" but "conform". And it is not required by the
compiler (that sometime provide a non conformant way to avoid that)
but by the standard.
Alain
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Steve Clamage <stephen.clamage@sun.com>
Date: 2000/06/21 Raw View
Sebastian Moleski wrote:
>
> <kanze@gabi-soft.de>:
> |
> |I just use the old names: <iostream.h>. I've yet to encounter a
> |compiler where this didn't work.
>
> It might work but it's not standard. If the following code compiles,
> the compiler cannot be called compliant:
>
> #include <iostream.h>
>
> int main() {
> cout << "Hello, World!" << endl;
> }
Not so. The standard says a compiler must accept particular header
spellings. It does not say a compiler cannot accept any others.
The standard does not mention a header spelled <iostream.h>,
so an implementation can choose to accept such a header without
violating any provision of the standard.
The use of <iostream.h> is not fully portable, however, because
1. No compiler is required by the standard to supply such a header, and
2. Among compilers that provide such a header, the meaning varies.
With some compilers, you get "classic" rather than standard iostreams.
With others, you get standard iostreams, but with the declarations
available in the global namespace. With Sun C++, you can get either
behavior, depending on a command-line option.
--
Steve Clamage, stephen.clamage@sun.com
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Steve Clamage <stephen.clamage@sun.com>
Date: 2000/06/21 Raw View
James Kuyper wrote:
>
>
> ... A conforming implementation is almost never required to reject
> any code. The standard often requires at least one diagnostic.
Right.
> However,
> the only case I can remember offhand where it prohibits successful
> translation is for code that contains a #error directive that survives
> conditional compilation.
Not even then. The only requirement on the #error directive is that
it result in a diagnostic message. The directive also renders the
program ill-formed, which means the standard places no further
requirements on the implemetation.
An implementation could choose to abort immediately, to continue
translating, or even to produce an object file.
--
Steve Clamage, stephen.clamage@sun.com
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Jim Hyslop <jim.hyslop@leitch.com>
Date: 2000/06/22 Raw View
Well, I already replied to this via RemarQ but that post doesn't seem to
have made it through for some reason. So this may be a duplicate post,
sorry about that.
In any case:
In article <mitch-3E4D27.12400619062000@news.brainstorm.net>,
Mitch Adler <mitch@intelligentparadigm.com> wrote:
> I trust that that Herb will independently verify any claims of
> non-conformance through direct testing and not just publish claims
> posted here, as many of these claims can be out of date from the
> current compiler state.
Speaking as one of those participating in the article, I can attest that
this newsgroup thread is only one aspect of the article Herb will
publish. Each compiler will be evaluated independently by several
people, and their comments will be reviewed by an expert panel.
The purpose of this thread is not necessarily to enumerate all known
non-conformance issues (particularly of a well-known compiler) but
rather to find out from the front-line programmer, who has to work with
these tools day in and day out, exactly what is important as far as
standards conformance goes.
F'rinstance, someone mentioned the scope of a variable declared in a
for-init-statement - is that really important, or just an annoyance?
IMO it's an annoyance, because it's something you can work around quite
easily.
--
Jim
I ignore all email from recruitment agencies. Except that
I reserve the right to send rude, nasty replies to recruiters.
Please do not send me email with questions - post
here.
Sent via Deja.com http://www.deja.com/
Before you buy.
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Thomas Engelmeier <moof4e4@my-deja.com>
Date: 2000/06/22 Raw View
> 2. Non-inline template definitions.
>
> I want to have the linker instantiate templates whose
implementation
> is separate from their declaration. This is the only way to
> break #include dependencies. The code which makes use of a
template
> should not have to include all of the interfaces used by the
> implementation of the template.
>
> Of the compilers with which I have experience, SGI's compiler
does this,
AND WILL BREAK SOME DAY LINKING IT...
reported three times, was "Not reproducible" in tiny testcases, sent
of..
Turning off precompiled headers helps..
> while the Metrowerks and MSVC++ compilers do not.
Why not?
Split it up into Template declaration (in a header), the
implemantation (in a source) and use explicit template
instantiation (in that source):
// this will generate all code for the Template TSmallInput<T, I>:
template class TSmallInput<int, CAdapter::kInt>;
Works on MIPS Pro xxx and Metrowerks CWP 4.x / 5.
AFAIR I used explicit instantiation also on VC++.
Have fun,
Tom_E
Sent via Deja.com http://www.deja.com/
Before you buy.
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Niels Dekker <ndekker@REMOVETHISnki.nl>
Date: 2000/06/22 Raw View
Herb Sutter wrote:
> What compiler/library conformance weaknesses matter to you in
> real-world production code?
Two wishes from me:
1. Better support for reference-to-C-style-array
In combination with templates, reference-to-C-style-arrays often
get rejected by compilers that we use at my work. The following
example will not compile for MSVC++ 5.0 and 6.0 (both SP 3):
template<typename ELEMENT_TYPE, unsigned uNumElements>
unsigned GetNumElements(
const ELEMENT_TYPE (&)[uNumElements]) // MSVC++ compiler error
{
return uNumElements;
}
The following use of a reference-to-C-style-array does no longer
compile with MSVC++ 6.0 (it did with MSVC++ 5.0):
template<unsigned uNumElements>
class TCMyIntegerArray
{
typedef int INT_ARRAY[uNumElements];
INT_ARRAY m_aiData;
public:
INT_ARRAY & GetData(void) // MSVC++ 6.0 compiler error
{
return m_aiData;
}
};
So now I always use a pointer-to-the-first-array-element even if a
reference-to-C-style-array would have been more appropriate.
Result: less strict type-checking, less solid coding :-(
2. Better support for alternative tokens of logical operators, like
"and", "or", and "not"
I still use &&, || and !, but personally I think "and", "or", and
"not" are much more readable. Especially if these tokens would have
been given syntax-highlighting in the IDE! Also we sometimes have to
convert Delphi/Pascal code to C++ and vise versa. This would have been
easier with the support of "and", "or", and "not", because these
tokens mean the same in both languages.
I'm surprised that even Borland C++ does not support "and", "or", and
"not", because in other aspects they made their C++Builder look very
simular to their Delphi/Pascal builder.
Regards from Amsterdam,
Niels Dekker
ndekker "at" nki "dot" nl
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Tom <the_wid@my-deja.com>
Date: 2000/06/22 Raw View
In article <jBA35.77033$nl3.267095@typhoon.ne.mediaone.net>,
"David Abrahams" <abrahams@mediaone.net> wrote:
[SNIP]
> So what if MSVC supports member templates if it doesn't support them
fully?
> Eventually you find out that you can't write object-
>member_function<Type>()
> *after* you've already checked your code with a more competent
compiler!
object->member_function<Type>();
Are you sure that's correct syntax? In my Stroustrup (section 17.5.3.3)
this line appears:
"cout << b.template to_string<char,char_traits<char>,allocator<char> >()
<< '\n';"
along with a comment about this being an elaborate and rare syntax. It
references C.13.6, but I searched this section in vain for a
description or explanation of this syntax. Josuttis' "The Standard C++
Library" has similar in its bitset section (just before the end of 10.4)
Can someone shed some light on this please? Is this the standard way of
explicitly specifying template arguments for member template functions?
Tom
Sent via Deja.com http://www.deja.com/
Before you buy.
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: James Kuyper <kuyper@wizard.net>
Date: 2000/06/22 Raw View
Steve Clamage wrote:
>
> James Kuyper wrote:
> >
> >
> > ... A conforming implementation is almost never required to reject
> > any code. The standard often requires at least one diagnostic.
>
> Right.
>
> > However,
> > the only case I can remember offhand where it prohibits successful
> > translation is for code that contains a #error directive that survives
> > conditional compilation.
>
> Not even then. The only requirement on the #error directive is that
> it result in a diagnostic message. The directive also renders the
> program ill-formed, which means the standard places no further
> requirements on the implemetation.
>
> An implementation could choose to abort immediately, to continue
> translating, or even to produce an object file.
My apologies. The last time I said "the standard doesn't require the
rejection of any program", I was refuted with a reference to #error. The
problem is, that was on comp.std.c, not comp.std.c++.
Section 4 p4 of the C99 standard says "The implementation shall not
successfully translate a preprocessing translation unit containing a
#error preprocessing directive unless it is part of a group skipped by
conditional inclusion." However, you're right - the C++98 standard
contains no such wording.
I know someone out there was keeping a list of the differences between
the languages. Does this need to be added to your list?
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Jim.Hyslop" <Jim.Hyslop@Leitch.com>
Date: 2000/06/22 Raw View
> In article <6oliksk6j5le2mhvqriabfqfr5eld15n4k@4ax.com>,
> Herb Sutter <hsutter@peerdirect.com> wrote:
> [snip]
> > What compiler/library conformance weaknesses matter to you in
> > real-world production code?
> Inconsistent adherence to the standard.
>
> I recently had to re-work a section of code that used a dynamic_cast to
> downcast a reference (not my design!!). I found that the following
> program:
>
> #include <iostream>
> #include <typeinfo>
>
> class base
> {
> public:
> virtual ~base() {}
> };
>
> class derived : public base
> {
> };
>
> int main()
> {
> try {
> base b;
> derived &d=dynamic_cast<derived &>(b);
> }
> catch (std::bad_cast &)
> {
> std::cout << "Good" << std::endl;
> }
> catch (...)
> {
> std::cout << "OH NO!!" << std::endl;
> }
> return 0; // BTW, this is a minor annoyance
> }
>
> would output "OH NO!!" instead of "Good".
>
> VC throws a "::bad_cast" class, which is defined in typeinfo.h Even
> using the compiler option which forces ANSI compliance (which, by the
> way, does not allow any standard headers to compile) results in
> ::bad_cast being thrown.
>
> To make matters worse, typeinfo.h is incompatible with *any* standard
> header, so I couldn't even insert a conditional section to catch
> ::bad_cast on MSVC, and std::bad_cast on other platforms, because I was
> using standard headers as well.
>
> --
> Jim
> I ignore all email from recruitment agencies. Except that
> I reserve the right to send rude, nasty replies to recruiters.
> Please do not send me email with questions - post
> here.
>
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: kanze@gabi-soft.de
Date: 2000/06/22 Raw View
cmd@gmrc.gecm.com (Chris Dearlove) writes:
|> kanze@gabi-soft.de wrote:
|> : I just use the old names: <iostream.h>. I've yet to encounter a
|> : compiler where this didn't work.
|> I have encountered a compiler where mixing <iostream> and
|> <iostream.h> doesn't work. In a multiple programmer environment
|> where some are attempting to "do the right thing" this is a problem.
I'd be surprised if mixing them did work. In a multiple programmer
environment, you must have coding guidelines, which all programmers
follow. If portability is one of the project requirements, such
guidelines should ban <iostream> (and a host of other new features). If
portability is not an issue, the project must decide which version to
use, and impose it.
|> My issues, or at least the ones which occur to me now, are
|> - Inability to catch exceptions thrown by initialisers to a
|> constructor.
There's no way to do this in portable code.
|> - Polluted headers (the principal problem being that of accidentally
|> omitting a standard required header because the code still
|> compiles but won't elsewhere of course).
The standard won't help you here. A standard header is allowed (but not
required) to include any other standard headers it wants.
|> - Missing <cxxxxxx> headers, only <xxxxxx.h> headers. (Missing non-C
|> <xxxxxx> headers has not been an issue.)
Don't use <cxxxxxx> headers in portable code. This is really not a
problem.
|> - Missing overloaded abs function, only abs(int). (Probably other
|> functions also, this is the one that's bitten.)
Again, don't use what isn't portably available. In this case, however,
I'd accept an alternative solution: provide your own version for the
compilers which don't have it.
|> - Implementation of exception specifications that is completely
|> useless (no compile time checking at all, so get all the
|> disadvantages and no advantages). This is a quality of
|> implementation issue rather than a standards issue however I
|> suppose.
It's a real standards issue -- compile time checking is NOT permitted by
the standard. As a quality of implementation issue, of course, one
would expect a warning. In practice, however, this shouldn't be a
portability issue -- some compilers will always give more warnings than
others.
--=20
James Kanze mailto:kanze@gabi-soft.de
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
Ziegelh=FCttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Hyman Rosen <hymie@prolifics.com>
Date: 2000/06/22 Raw View
Tom <the_wid@my-deja.com> writes:
> object->member_function<Type>();
>
> Are you sure that's correct syntax?
Yes, except in templates. Here's an example -
struct A { template <int N> int get(int x) { return N + x; } };
struct B { enum { get = 0 } };
struct C { enum { get = 1 } };
int f()
{
return A().get<1>(0); // This is OK
}
template <typename Z> int g()
{
return Z().get<1>(0); // What are g<A>(), g<B>(), and g<C>()?
}
To disambiguate this, in a template C++ assumes that you are not
referring to a member template unless you use the template keyword:
template <typename Z> int g()
{
return Z().template get<1>(0);
}
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: James Kuyper <kuyper@wizard.net>
Date: 2000/06/22 Raw View
Tom wrote:
....
> object->member_function<Type>();
>
> Are you sure that's correct syntax? In my Stroustrup (section 17.5.3.3)
> this line appears:
> "cout << b.template to_string<char,char_traits<char>,allocator<char> >()
> << '\n';"
I don't see a contradiction. The difference between '->' and '.' is
explained by 'object' being a pointer to an object, while 'b' is itself
an object. The larger number of template arguments for 'to_string' is
simply due to the fact that it has more template parameters than
'member_function'. The two examples are consistent with each other.
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: kanze@gabi-soft.de
Date: 2000/06/22 Raw View
"Gillmer J. Derge" <gderge1@nycap.rr.com> writes:
|> "Garth A. Dickie" wrote:
|> > 1. New-style header names, with the standard library in namespace s=
td.
|> > When I write code which is intended to be portable between compiler=
s,
|> > and I want to use the C++ standard library, I would like to use the=
new
|> > style header names. This is particularly important for <iostream> a=
nd
|> > <sstream>, where the old header names provide different functionali=
ty.
|> > When I have to deal with a mixture of behavior in the compilers, I =
end
|> > up with a mess of #ifdef stuff, and no namespaces.
|> This one is especially frustrating given how easy it would be to
|> fix. Any compiler vendor that cares even a whit about conformance
|> could spend 5 minutes creating some trivial header files
|> (ex. vector: #include <vector.h>), and in one fell swoop the problem
|> is solved.
It's not that simple for the iostream stuff. If I include <iostream>
(which I don't in portable code), I expect a templated basic_istream,
etc., and the possibility to set the locale on an individual stream.
Which is far from trivial. In portable code, of course, I only include
<iostream.h>, which I expect to give me the classical iostream's, with
significantly less functionality.
--=20
James Kanze mailto:kanze@gabi-soft.de
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
Ziegelh=FCttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: kanze@gabi-soft.de
Date: 2000/06/22 Raw View
"David Abrahams" <abrahams@mediaone.net> writes:
|> So what if MSVC supports member templates if it doesn't support them
|> fully? Eventually you find out that you can't write
|> object->member_function<Type>() *after* you've already checked your
|> code with a more competent compiler! Eventually you find out that
|> they only work if you declare them in the class body. Maybe it's
|> better to just assume they don't work!
But isn't this true for most compilers, with respect to most new
features. I've been experimenting with member templates with g++, which
seems to do a remarkably good job with them. But I certainly wouldn't
consider them a feature to be used in "portable" code yet.
--=20
James Kanze mailto:kanze@gabi-soft.de
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
Ziegelh=FCttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: kanze@gabi-soft.de
Date: 2000/06/22 Raw View
"Sebastian Moleski" <sebmol@gmx.net> writes:
|> <kanze@gabi-soft.de>:
|> | "Garth A. Dickie" <Garth_Dickie@avid.com> writes:
|> |> 1. New-style header names, with the standard library in
|> |> namespace std.
|> |> When I write code which is intended to be portable between
|> |> compilers, and I want to use the C++ standard library, I would
|> |> like to use the new style header names. This is particularly
|> |> important for <iostream> and <sstream>, where the old header
|> |> names provide different functionality. When I have to deal with
|> |> a mixture of behavior in the compilers, I end up with a mess of
|> |> #ifdef stuff, and no namespaces.
|> |I just use the old names: <iostream.h>. I've yet to encounter a
|> |compiler where this didn't work.
|> It might work but it's not standard.
I know. On the other hand, standard conforming code doesn't work with
many compilers, starting with g++. You have the choice: standard
conforming, or portable working code.
In the end, today, the easiest way to write portable code is just to
choose a single, retargeted compiler, and write to it. The one I'm
familiar with is g++ 2.95.2: very strong in templates, but decidely
mixed in the library. So my code contains <strstream.h> but
<vector>:-). I'd obviously prefer everything standard, but not as much
as I prefer working code.
If you only have to target a few known platforms, you can also consider
defining a common subset of several compilers. Thus, for example, both
VC++ and Sun CC support the new iostream and sstream -- if you *know*
that you will only have to target Windows and Solaris, the commun subset
is probably closer to the standard than what g++ offers.
|> If the following code compiles,
|> the compiler cannot be called compliant:
|> #include <iostream.h>
|> int main() {
|> cout << "Hello, World!" << endl;
|> }
So. If I write the following code, I can't compile it with the most
widespread compiler I know:
#include <sstream>
Standards are only useful if they are followed. For the moment, the C++
standard is more of accademic interest than anything else. Or rather,
it's real interest is in specifying the long term goals of the compiler
vendors. At any rate, it's not a very useful document for writing
portable code today.
|> |> 2. Non-inline template definitions.
|> |> I want to have the linker instantiate templates whose
|> |> implementation is separate from their declaration. This is the
|> |> only way to break #include dependencies. The code which makes
|> |> use of a template should not have to include all of the
|> |> interfaces used by the implementation of the template.
|> |> Of the compilers with which I have experience, SGI's compiler
|> |> does this, while the Metrowerks and MSVC++ compilers do not.
|> | And I'm willing to bet that in this regard, it's VC++ which is
|> | conform, and NOT SGI.
|> Why? Do you think it is right that compilers require template
|> definitions to be in header files?
What I think is right doesn't count. Regretfully, because I really
think that separate compilation of templates is important. The
standard, however, states that unless the template is exported (and no
compiler that I know of to date supports export, except Visual Age,
which does so in a decidely non-conforming manner), the entire
implementation is required in each translation unit which uses the
template.
--=20
James Kanze mailto:kanze@gabi-soft.de
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
Ziegelh=FCttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: kanze@gabi-soft.de
Date: 2000/06/22 Raw View
Jim Hyslop <jim.hyslop@leitch.com> writes:
|> F'rinstance, someone mentioned the scope of a variable declared in a
|> for-init-statement - is that really important, or just an annoyance?
|> IMO it's an annoyance, because it's something you can work around
|> quite easily.
Right. In practice, in my code, if it works with the new scope, it will
work with the old, since my functions are all extremely small, and I
can't think of any where I have multiple for loops.
But the relative importance of issues will probably vary greatly from
one programmer to the next. I'd rate the presence or absense of
<sstream> and <limits> as the most bothersome issue I have to deal with,
followed by <locale> and member templates. But of course, for
<sstream>, I can and do use <strstream.h>.
--=20
James Kanze mailto:kanze@gabi-soft.de
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
Ziegelh=FCttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: James Kuyper <kuyper@wizard.net>
Date: 2000/06/23 Raw View
kanze@gabi-soft.de wrote:
>
> cmd@gmrc.gecm.com (Chris Dearlove) writes:
....
> |> I have encountered a compiler where mixing <iostream> and
> |> <iostream.h> doesn't work. In a multiple programmer environment
> |> where some are attempting to "do the right thing" this is a problem.
>
> I'd be surprised if mixing them did work. In a multiple programmer
> environment, you must have coding guidelines, which all programmers
> follow. If portability is one of the project requirements, such
> guidelines should ban <iostream> (and a host of other new features). If
> portability is not an issue, the project must decide which version to
> use, and impose it.
If portability to non-standard implementations is an issue, you must
also ban <iostream.h>. It worked in many different incompatible ways
under different pre-standard implementations. Your only choice, if your
code must be compatible with non-standard implementations, is to define
your own string library, that doesn't use reserved names, and package it
with your code.
> |> My issues, or at least the ones which occur to me now, are
>
> |> - Inability to catch exceptions thrown by initialisers to a
> |> constructor.
>
> There's no way to do this in portable code.
See section 15p3, describing and demonstrating the use
function-try-blocks in a constructor, to catch exceptions generated by
the initializers. That code is supposed to be portable to any conforming
implementation. Since this thread is about conformance issues, that is
an entirely legitimate complaint, even (or perhaps especially) if this
is an extremely common form of non-conformance.
....
> Don't use <cxxxxxx> headers in portable code. This is really not a
> problem.
That pollutes the global namespace, which is most definately a problem.
> |> - Missing overloaded abs function, only abs(int). (Probably other
> |> functions also, this is the one that's bitten.)
>
> Again, don't use what isn't portably available. In this case, however,
You're missing the point. Look at the title of this thread. The
overloaded abs() function is supposed to be portably available. The fact
that it isn't is a legitimate conformance issue.
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: comeau@panix.com (Greg Comeau)
Date: 2000/06/23 Raw View
In article <86snu5q5gx.fsf@gabi-soft.de>, <kanze@gabi-soft.de> wrote:
>It's not that simple for the iostream stuff. If I include <iostream>
>(which I don't in portable code), I expect a templated basic_istream,
>etc., and the possibility to set the locale on an individual stream.
>Which is far from trivial. In portable code, of course, I only include
><iostream.h>, which I expect to give me the classical iostream's, with
>significantly less functionality.
I'm having a problem following this. If <iostream> is not
portable, apparently because you find it either not available,
or incompatible with each other when available, it does not
follow that <iostream.h> solves this, because said implementations
were (and still are) also incompatible, not to mention the original
iostreams spec had serious problems. So I agree it's not that simple,
but I don't see how iostream.h makes it not not simple, as it
just remains problematic at a different level. So talking about
portable code in this respect is somewhat illusory. And although
I appreciate that this works to the subset you're coding it too,
and so from that context it's portable (portability is relative,
so I accept this) but what about persons coding it to another subset
(or superset)? And what about the Standard? What would make you
change, and why?
- Greg
--
Comeau Computing / Comeau C/C++ 4.2.42 (4.2.44 expected soon)
TRY Comeau C++ ONLINE at http://www.comeaucomputing.com/tryitout
Email: comeau@comeaucomputing.com / WEB: http://www.comeaucomputing.com
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: mcnepp@my-deja.com
Date: 2000/06/23 Raw View
In article <mitch-F21967.17022816062000@news.brainstorm.net>,
Mitch Adler <mitch@intelligentparadigm.com> wrote:
> Here are a few we ran into recently porting our code from Code
Warrior
> to GC++ and VC++ 6:
>
> A) Out of line class-template member implementation support.
>
> Several compilers do not support out of line class-template
> implementations, notably GC++ 2.95.5 and VC++6. Metrowerks Codwarrior
> does.
>
> This forces the inlining of implementations in the declaration.
>
I don't know how you reached the conclusion that VC++6 and gcc do not
support non-inline template-class members. For me, this has worked
perfectly well with both of these compilers.
The one notable the exception is VC's inability to instantiate _nested_
classes within template classes unless they're completely inline.
Here's an example that will compile but not link with VC:
template<class T> class Bar
{
class Imp
{
friend class Bar<T>;
Imp();
};
};
template<class T> Bar<T>::Imp::Imp
{
}
Sent via Deja.com http://www.deja.com/
Before you buy.
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Sam Lindley" <sam@redsnapper.net>
Date: 2000/06/23 Raw View
<kanze@gabi-soft.de> wrote in message news:86g0q5q4dq.fsf@gabi-soft.de...
"Sebastian Moleski" <sebmol@gmx.net> writes:
[...]
> I know. On the other hand, standard conforming code doesn't work with
> many compilers, starting with g++. You have the choice: standard
> conforming, or portable working code.
>
> In the end, today, the easiest way to write portable code is just to
> choose a single, retargeted compiler, and write to it. The one I'm
> familiar with is g++ 2.95.2: very strong in templates, but decidely
> mixed in the library. So my code contains <strstream.h> but
> <vector>:-). I'd obviously prefer everything standard, but not as much
> as I prefer working code.
Why not use SGIs implementation?
(http://www.sgi.com/Technology/STL/standard_library.html)
Sam Lindley
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: kanze@gabi-soft.de
Date: 2000/06/23 Raw View
Steve Clamage <stephen.clamage@sun.com> writes:
|> The use of <iostream.h> is not fully portable, however, because
|> 1. No compiler is required by the standard to supply such a header, a=
nd
|> 2. Among compilers that provide such a header, the meaning varies.
|> With some compilers, you get "classic" rather than standard iostreams.
|> With others, you get standard iostreams, but with the declarations
|> available in the global namespace. With Sun C++, you can get either
|> behavior, depending on a command-line option.
The use of <iostream.h> may not be fully portable, but it is currently
more portable than <iostream>. Concerning the two potential problems
that Steve mentioned:
1. All of the compilers I know provide it. I cannot imagine a compiler
not providing it -- breaking existing customer code is not a good
marketing technique, and as the header existed in older versions, it
costs very little to provide it.
2. All of the compilers I know provide the "classic" iostream with this
header. (At least one compiler I know provides the "classic"
iostream with <iostream> as well. IMHO, this is a mistake.)
There is an additional problem: interpretations of the "classic"
iostream vary, so you have to be prepared for some degree of variance
here as well. But it is manageable, and IMHO, the results are still
more manageable than strewing the code with #if's to use the standard
iostream when available, and the classic when not.
--=20
James Kanze mailto:kanze@gabi-soft.de
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
Ziegelh=FCttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Hyman Rosen <hymie@prolifics.com>
Date: 2000/06/23 Raw View
James Kuyper <kuyper@wizard.net> writes:
> Tom wrote:
> ....
> > object->member_function<Type>();
> >
> > Are you sure that's correct syntax? In my Stroustrup (section 17.5.3.3)
> > this line appears:
> > "cout << b.template to_string<char,char_traits<char>,allocator<char> >()
> > << '\n';"
>
> I don't see a contradiction
You missed '.template to_string<...>' vs. '->member_function<...>'.
That's the keyword 'template' used after the '.' or '->'.
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: James Kuyper <kuyper@wizard.net>
Date: 2000/06/23 Raw View
Hyman Rosen wrote:
>
> James Kuyper <kuyper@wizard.net> writes:
> > Tom wrote:
> > ....
> > > object->member_function<Type>();
> > >
> > > Are you sure that's correct syntax? In my Stroustrup (section 17.5.3.3)
> > > this line appears:
> > > "cout << b.template to_string<char,char_traits<char>,allocator<char> >()
> > > << '\n';"
> >
> > I don't see a contradiction
>
> You missed '.template to_string<...>' vs. '->member_function<...>'.
> That's the keyword 'template' used after the '.' or '->'.
Yes, I noticed it about 4 hours after posting the message.
Unfortunately, 'Cancel Message' commands can't be made retroactive :-(.
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: cmd@gmrc.gecm.com (Chris Dearlove)
Date: 2000/06/24 Raw View
kanze@gabi-soft.de wrote:
: cmd@gmrc.gecm.com (Chris Dearlove) writes:
: If portability is one of the project requirements, such
: guidelines should ban <iostream> (and a host of other new features).
This I think misses the point of this thread, which is that if more
compilers were more standard compliant then we could Do The Right
Thing (which banning <iostream> is definitely not) and be portable.
: |> - Inability to catch exceptions thrown by initialisers to a
: |> constructor.
: There's no way to do this in portable code.
But there is in the standard (reference not to hand, Stroustrup 3rd ed.
14.4.6.1) and that is the point of his thread.
: |> - Polluted headers (the principal problem being that of accidentally
: |> omitting a standard required header because the code still
: |> compiles but won't elsewhere of course).
: The standard won't help you here. A standard header is allowed (but not
: required) to include any other standard headers it wants.
Have you got a standard reference for this. I believe this is not the
case in C, is C++ that different?
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Garth A. Dickie" <Garth_Dickie@avid.com>
Date: 2000/06/24 Raw View
I wrote:
> I want to have the linker instantiate templates whose
> implementation is separate from their declaration.
Thomas Engelmeier <moof4e4@my-deja.com> writes:
> Split it up into Template declaration (in a header), the
> implemantation (in a source) and use explicit template
> instantiation (in that source):
Well, I really do want to have the linker do the instantiation,
rather then using explicit instantiation. But your point is
well taken; if it is possible to know which instantiations are
needed, then I can break the #include dependency this way.
For the example I was thinking of, I was using a technique
similar to expression templates. In particular, the actual
types on which the templates were instantiated were pointers
to member functions of types unknown to me as a library
author, with arguments types unknown to me, etc.
Regards,
Garth A. Dickie
Sent via Deja.com http://www.deja.com/
Before you buy.
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Sam Lindley" <sam@redsnapper.net>
Date: 2000/06/24 Raw View
"Scott Meyers" <smeyers@aristeia.com> wrote in message
news:MPG.13b75ee032fae4f39896fd@news.supernews.com...
[...]
> Can you be more precise about what you want in the way of member templates
> that MSVC fails to offer?
AFAIK the main drawback of member templates in MSVC is that they have to be
defined inline. This can be annoying for those of us who wish to write our
own member templates, however it doesn't seem to have been too much of a
problem for the latest version of the Dinkum library, as all template
members were already defined inline anyway.
> My primary reason for posting this is to highlight the importance of
> distinguishing between what a *compiler* does or does not offer and what a
> *library* does or does not offer. For MSVC, the discrepancy seems to be
> particularly noteworthy.
Agreed. Very important in this case. The latest Dinkum library is much more
up-to-date than the one shipped with the compiler. However, many people will
be reluctant to pay to upgrade the library, and it can be problematic when
linking to third party libraries. IMO if MS were to ship the later version
of the library, it would significantly improve the perceived level of
conformance of the compiler.
Sam Lindley
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Mitch Adler <mitch@intelligentparadigm.com>
Date: 2000/06/24 Raw View
In article <mitch-F21967.17022816062000@news.brainstorm.net>, Mitch
Adler <mitch@intelligentparadigm.com> wrote:
>A) Out of line class-template member implementation support.
It has been pointed out that this was too sweeping a description (by
refuting the cases that I claimed).
After going back and reducing the problem from the actual code, instead
of inferring, I found that:
Out of line class-template specializations members are not correctly
supported out of line.
This code compile on GC++ 2.95.2:
template <typename T>
class MyClass
{
public:
typedef T value_type;
public:
MyClass(value_type initial);
};
template<>
class MyClass<int>
{
public:
typedef int value_type;
public:
MyClass(value_type initial = false);
};
template <>
inline
MyClass<int>::MyClass(value_type initial)
{
// This space intentionally left blank
}
Gives me:
foo.cp:29: template-id `MyClass<>' for `MyClass<int>::MyClass(int)' does
not match any template declaration
foo.cp:29: syntax error before `{'
I have not tested for this directly in VC++, but there is a related
problem, cured by inlining these definitions.
>
>Several compilers do not support out of line class-template
>implementations, notably GC++ 2.95.5 and VC++6. Metrowerks Codwarrior
>does.
>
>This forces the inlining of implementations in the declaration.
These comments still apply, but to a smaller percentage of the populace.
Though, if specialization definitions must me inlined in the header,
often we will assume that all must be (as I have done).
Mitch
------------------------------------------------------------------------
Mitch Adler "There are people in the world who
Intelligent Paradigm do not love their fellow human beings,
Mitch@mitch.org and I hate people like that."
Mitch@IntelligentParadigm.com - Tom Lehrer
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: llewelly@brownie.frogger.foobar.snot
Date: 2000/06/24 Raw View
"David Abrahams" <abrahams@mediaone.net> writes:
> "Scott Meyers" <smeyers@aristeia.com> wrote in message
> news:MPG.13b75ee032fae4f39896fd@news.supernews.com...
>
> > MSVC offers member templates, though my understanding is that they have
> > their limitations.
>
> Ugh! Let me just go out on a limb here and say that the non-conformance
> issues with MSVC are too gnarly and numerous to list properly.
[snip lots of text about msvc++]
I have not used msvc++ (well, not in over 2 years), but I would claim
that for most modern c++ compilers, the bugs cannot be easily
summarized. In general, one cannot simply say 'Compiler X does not
support feature Y'. (If one does, one often finds out one was thinking
of compiler X as it was a few years ago.)
Usually, bugs must be described by particular code examples, sometimes
very long examples.
This is often one of the more frustrating aspects of porting C++; one
does not know if a particular piece of code will work until one
tries it. (If there is a public bug database, that can be useful,
but not as reliable. Web submission forms can also be useful here.)
If one could say 'compiler X does not support member templates' things
would in some respects be much simpler. But that is not usually the
case; compiler X *does* support member templates; it just has (for
example) some weird bugs that no-one remembers exactly how to
reproduce.
The fact that almost no-one has time to become familiar with more than
one compiler is an additional problem.
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Francis Glassborow <francis@robinton.demon.co.uk>
Date: 2000/06/25 Raw View
In article <8ivugh$qcd$1@miranda.gmrc.gecm.com>, Chris Dearlove
<cmd@gmrc.gecm.com> writes
>: The standard won't help you here. A standard header is allowed (but not
>: required) to include any other standard headers it wants.
>
>Have you got a standard reference for this. I believe this is not the
>case in C, is C++ that different?
C specifically prohibits any standard header from including any other
standard header (which is one reason why some macros appear in more than
one header)
C++ assumes that any header can include any other header. Yes, that was
a deliberate and considered action. It cannot have any impact on legacy
C code.
Francis Glassborow Association of C & C++ Users
64 Southfield Rd
Oxford OX4 1PA +44(0)1865 246490
All opinions are mine and do not represent those of any organisation
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Steve Clamage <stephen.clamage@sun.com>
Date: 2000/06/25 Raw View
Chris Dearlove wrote:
>
> : |> - Polluted headers (the principal problem being that of accidentally
> : |> omitting a standard required header because the code still
> : |> compiles but won't elsewhere of course).
>
> : The standard won't help you here. A standard header is allowed (but not
> : required) to include any other standard headers it wants.
>
> Have you got a standard reference for this. I believe this is not the
> case in C, is C++ that different?
It's not allowed in C, but is explicitly allowed in C++.
Section 17.4.4.1 "Headers":
"A C++ header may include other C++ headers."
A footnote adds:
"C++ headers must include a C++ header that contains any needed definition."
--
Steve Clamage, stephen.clamage@sun.com
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: kanze@gabi-soft.de
Date: 2000/06/25 Raw View
comeau@panix.com (Greg Comeau) writes:
|> In article <86snu5q5gx.fsf@gabi-soft.de>, <kanze@gabi-soft.de> wrote=
:
|> >It's not that simple for the iostream stuff. If I include <iostream=
>
|> >(which I don't in portable code), I expect a templated basic_istream=
,
|> >etc., and the possibility to set the locale on an individual stream.
|> >Which is far from trivial. In portable code, of course, I only incl=
ude
|> ><iostream.h>, which I expect to give me the classical iostream's, wi=
th
|> >significantly less functionality.
|> I'm having a problem following this. If <iostream> is not
|> portable, apparently because you find it either not available,
|> or incompatible with each other when available, it does not
|> follow that <iostream.h> solves this, because said implementations
|> were (and still are) also incompatible, not to mention the original
|> iostreams spec had serious problems. So I agree it's not that simple=
,
|> but I don't see how iostream.h makes it not not simple, as it
|> just remains problematic at a different level.
Today, there is a greater probability that your code will work with
different compilers if you include <iostream.h> than if you include
<iostream>. The opposite should be true, but in practice, it's not.
|> So talking about
|> portable code in this respect is somewhat illusory.
Talking about 100% portable code is illusory in any context.
|> And although
|> I appreciate that this works to the subset you're coding it too,
|> and so from that context it's portable (portability is relative,
|> so I accept this) but what about persons coding it to another subset
|> (or superset)? And what about the Standard? What would make you
|> change, and why?
What would make me change is simply most of the mainstream compilers
supporting the new iostream. At present, I know of one that doesn't,
g++. Given 1) the price, 2) the stability of the compiler and the
libraries, and 3) the availability on different platforms, it is an
important compiler for me.
Now if Comeau came with the Dinkumware library, you'd probably beat them
on 2 and 3, and your prices are reasonable too, so maybe I'd
consider:-). But at present, it doesn't.
Similarly, I know that there are conforming parts of the library
compatible with g++ available freely on the net. By grabbing a bit
here, and a bit there, I think you could probably come up with a 99%
conform library for g++. But I have other things to do with my time.
Downloading and installing g++ took me under 5 minutes of my time. It
works *if* I use <iostream.h> and <strstream.h>. And the code that I
develop in these conditions also works with Sun CC 5.0. And (I think)
with VC++ 6.0. And probably with most other compilers. It bothers me
that I don't have <sstream> and company, but it doesn't prevent me from
doing significant work. I could use <sstream> with the Sun compiler,
but then it wouldn't be portable to g++.
--=20
James Kanze mailto:kanze@gabi-soft.de
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
Ziegelh=FCttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: =?ISO-8859-1?Q?J=F6rg?= Barfurth <joerg.barfurth@attglobal.net>
Date: 2000/06/25 Raw View
Am 24.06.00, 05:07:55, schrieb Mitch Adler <mitch@intelligentparadigm.com=
>=20
zum Thema Re: RFD: C++ Compiler/Library Conformance Issues:
> Out of line class-template specializations members are not correctly
> supported out of line.
> This code compile on GC++ 2.95.2:
> template <typename T>
> class MyClass
> {
> public:
> typedef T value_type;
> public:
> MyClass(value_type initial);
> };
Fine - a class template.
> template<>
> class MyClass<int>
> {
> public:
> typedef int value_type;
> public:
> MyClass(value_type initial =3D false);
> };
An explicit specialization. From here on 'MyClass<int>' is just a name=20
for a class, you dont need specialization syntax to define its members=20
any more.
> template <> // This you dont need
> inline
> MyClass<int>::MyClass(value_type initial)
> {
> // This space intentionally left blank
> }
The compiler might view that as an attempt to specialize a member of the=20
general class template (which is illegal as the class template has been=20
specialized as a whole already).
> Gives me:
> foo.cp:29: template-id `MyClass<>' for `MyClass<int>::MyClass(int)' doe=
s
> not match any template declaration
> foo.cp:29: syntax error before `{'
The error message is misleading, but you might try this without=20
'template<>' on the member definition.
What does yout compiler say then ?
-- J=F6rg
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Mitch Adler <mitch@intelligentparadigm.com>
Date: 2000/06/18 Raw View
In article <6oliksk6j5le2mhvqriabfqfr5eld15n4k@4ax.com>, Herb Sutter
<hsutter@peerdirect.com> wrote:
>
> ==================================================================
>
> RFD Question:
>
> What compiler/library conformance weaknesses matter to you in
> real-world production code?
Here are a few we ran into recently porting our code from Code Warrior
to GC++ and VC++ 6:
A) Out of line class-template member implementation support.
Several compilers do not support out of line class-template
implementations, notably GC++ 2.95.5 and VC++6. Metrowerks Codwarrior
does.
This forces the inlining of implementations in the declaration.
For non-trivial class-template member implementations the act of
inlining them in the class declaration causes clutter for clients and
reduces the separation of interface and implementation.
This causes confusion for those using and those learning about and those
maintaining class template.
Additionally, it requires that we suggest that the compiler to inline
our code (as inline implementations implicty are 'inline'). In
development this can hamper debuggin, though many compilers permit
turning off of inlining.
B) Conversions from binary operators.
VC++ 6 does not invoke user supplied conversions for binary operators
(<, >, etc.). This breaks any code depending on conversions at compile
time.
To work around this problem, the comparison site must know which object
can be converted and explicitly cast it. This makes the relationship
between the two types known at the call site (i.e. knowing which can be
converted and the type to convert to), increasing the brittleness of the
code.
C) For-loop variable scoping.
Several compilers still support ARM scoping (continuing to the end of
the scope containing the for statement) of for loop variables.
This causes same-level scoped for-loops with identical variables to
conflict.
This hampers porting efforts, though it is realtively easily worked
around if anticipated.
It's an education issue, also, as all engineers need to learn this to
eliminate headaches at porting time.
Weighting them by importance A would be 5x more important than B which
would be 2x more important than C.
All of them cost us time and energy much better spent dealing with the
mirad of other issues involved in porting.
A & B both reduced the quality of the portable (with respect to the C++
standard) code base.
Mitch
------------------------------------------------------------------------
Mitch Adler "There are people in the world who
Intelligent Paradigm do not love their fellow human beings,
Mitch@mitch.org and I hate people like that."
Mitch@IntelligentParadigm.com - Tom Lehrer
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Gillmer J. Derge" <gderge1@nycap.rr.com>
Date: 2000/06/18 Raw View
"Garth A. Dickie" wrote:
> 1. New-style header names, with the standard library in namespace std.
>
> When I write code which is intended to be portable between compilers,
> and I want to use the C++ standard library, I would like to use the new
> style header names. This is particularly important for <iostream> and
> <sstream>, where the old header names provide different functionality.
>
> When I have to deal with a mixture of behavior in the compilers, I end
> up with a mess of #ifdef stuff, and no namespaces.
This one is especially frustrating given how easy it would be to fix. Any
compiler vendor that cares even a whit about conformance could spend 5
minutes creating some trivial header files (ex. vector: #include <vector.h>),
and in one fell swoop the problem is solved.
I am not aware of any specific compilers that have this problem, though I
don't doubt that there are some. On second thought, the last version of
SGI's compiler that I used did not have a "cassert," but I'm not sure if that
was the most up to date version available. Most likely the other "c*"
variants of the C header files were also missing, but I did not check, as
they were not needed for my application.
I would add lack of partial specialization (and thus lack of proper support
for traits) and lack of template member functions as two fairly significant
problems (for me). Both of these issues are present in Microsoft Visual C++
and perhaps in other compilers.
-----
Gillmer J. Derge
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: kanze@gabi-soft.de
Date: 2000/06/18 Raw View
"Garth A. Dickie" <Garth_Dickie@avid.com> writes:
|> 1. New-style header names, with the standard library in namespace std.
|> When I write code which is intended to be portable between
|> compilers, and I want to use the C++ standard library, I would like
|> to use the new style header names. This is particularly important
|> for <iostream> and <sstream>, where the old header names provide
|> different functionality.
|> When I have to deal with a mixture of behavior in the compilers, I en=
d
|> up with a mess of #ifdef stuff, and no namespaces.
I just use the old names: <iostream.h>. I've yet to encounter a
compiler where this didn't work.
|> 2. Non-inline template definitions.
|> I want to have the linker instantiate templates whose implementation
|> is separate from their declaration. This is the only way to
|> break #include dependencies. The code which makes use of a template
|> should not have to include all of the interfaces used by the
|> implementation of the template.
|> Of the compilers with which I have experience, SGI's compiler does th=
is,
|> while the Metrowerks and MSVC++ compilers do not.
And I'm willing to bet that in this regard, it's VC++ which is conform,
and NOT SGI.
--=20
James Kanze mailto:kanze@gabi-soft.de
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
Ziegelh=FCttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: kanze@gabi-soft.de
Date: 2000/06/18 Raw View
Mitch Adler <mitch@intelligentparadigm.com> writes:
|> Here are a few we ran into recently porting our code from Code Warrio=
r=20
|> to GC++ and VC++ 6:
|> A) Out of line class-template member implementation support.
|> Several compilers do not support out of line class-template=20
|> implementations, notably GC++ 2.95.5 and VC++6. Metrowerks Codwarrior=
=20
|> does.
Do you mean that Metroworks supports "export", or that it has a
non-conforming extension.
[...]
|> C) For-loop variable scoping.
|> Several compilers still support ARM scoping (continuing to the end of=
=20
|> the scope containing the for statement) of for loop variables.
|> This causes same-level scoped for-loops with identical variables to=20
|> conflict.
|> This hampers porting efforts, though it is realtively easily worked=20
|> around if anticipated.
Strange. I've never written a function with more than one for loop in
it (at least, that wasn't nested). I don't find this to be a problem.
--=20
James Kanze mailto:kanze@gabi-soft.de
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
Ziegelh=FCttenweg 17a, 60598 Frankfurt, Germany Tel. +49(069)63198627
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "David Abrahams" <abrahams@mediaone.net>
Date: 2000/06/19 Raw View
I think means that template member functions and classes must be defined
within the enclosing class body on VC++. I do wonder about GC++ 2.95.5,
though. At first I thought he was referring to GCC (G++), but that compiler
is only up to v. 2.95.2. Furthermore, I know that GCC 2.95.2 supports
out-of-line template member function definitions.
-Dave
<kanze@gabi-soft.de> wrote in message news:86hfasi12r.fsf@gabi-soft.de...
Mitch Adler <mitch@intelligentparadigm.com> writes:
|> Here are a few we ran into recently porting our code from Code Warrior
|> to GC++ and VC++ 6:
|> A) Out of line class-template member implementation support.
|> Several compilers do not support out of line class-template
|> implementations, notably GC++ 2.95.5 and VC++6. Metrowerks Codwarrior
|> does.
Do you mean that Metroworks supports "export", or that it has a
non-conforming extension.
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: cmd@gmrc.gecm.com (Chris Dearlove)
Date: 2000/06/19 Raw View
kanze@gabi-soft.de wrote:
: I just use the old names: <iostream.h>. I've yet to encounter a
: compiler where this didn't work.
I have encountered a compiler where mixing <iostream> and <iostream.h>
doesn't work. In a multiple programmer environment where some are
attempting to "do the right thing" this is a problem.
My issues, or at least the ones which occur to me now, are
- Inability to catch exceptions thrown by initialisers to a constructor.
- Polluted headers (the principal problem being that of accidentally
omitting a standard required header because the code still compiles
but won't elsewhere of course).
- Missing <cxxxxxx> headers, only <xxxxxx.h> headers. (Missing non-C
<xxxxxx> headers has not been an issue.)
- Missing overloaded abs function, only abs(int). (Probably other
functions also, this is the one that's bitten.)
- Implementation of exception specifications that is completely useless
(no compile time checking at all, so get all the disadvantages and
no advantages). This is a quality of implementation issue rather
than a standards issue however I suppose.
Please note that these are from a definite non-guru, so don't probe
the extremes of the standard, but are just things I've come across
primarily from a single compiler (which shall be nameless, but is
from a major vendor and is generally pretty good I believe). Only
the first of these is a significantly style-cramping thing.
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Claude Qu zel" <Claude_Quezel@Syntell.corba>
Date: 2000/06/19 Raw View
Herb Sutter wrote:
> What compiler/library conformance weaknesses matter to you in
> real-world production code?
On the project I am working on right now, my real pain comes when I use the
compiler (yes that one :)) that does not support covariant return types.
--
Claude Qu zel (claude_quezel@syntell.corba)
anti-spam: replace corba by com in private replies
[ Send an empty e-mail to c++-help@netlab.cs.rpi.edu for info ]
[ about comp.lang.c++.moderated. First time posters: do this! ]
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: smeyers@aristeia.com (Scott Meyers)
Date: 2000/06/20 Raw View
On Sun, 18 Jun 2000 08:34:31 CST, Gillmer J. Derge wrote:
> I would add lack of partial specialization (and thus lack of proper support
> for traits) and lack of template member functions as two fairly significant
> problems (for me). Both of these issues are present in Microsoft Visual C++
Can you be more precise about what you want in the way of member templates
that MSVC fails to offer?
MSVC offers member templates, though my understanding is that they have
their limitations. In my experience, many programmers believe that MSVC
lacks member template support, because the *library* that ships with MSVC
fails to include member templates. (There is a history behind why this is
so, but it is not germane to the technical issues here.) At a recent
hands-on seminar I hosted on the STL that, at least trivially, exercised
large portions of the STL, people using the latest MSVC in conjunction with
the latest Dinkumware STL (which is *not* the same as the one shipping with
MSVC) ran into no restrictions imposed by the lack of member template
support in MSVC. This doesn't mean that MSVC's implementation of member
templates is fully conforming. It doesn't mean that it's even mostly
conforming. But it does mean that MSVC *does* offer member templates and
they *do* work, at least some of the time.
My primary reason for posting this is to highlight the importance of
distinguishing between what a *compiler* does or does not offer and what a
*library* does or does not offer. For MSVC, the discrepancy seems to be
particularly noteworthy.
Scott
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Sebastian Moleski" <sebmol@gmx.net>
Date: 2000/06/20 Raw View
<kanze@gabi-soft.de>:
| "Garth A. Dickie" <Garth_Dickie@avid.com> writes:
|> 1. New-style header names, with the standard library in namespace
std.
|
|> When I write code which is intended to be portable between
|> compilers, and I want to use the C++ standard library, I would
like
|> to use the new style header names. This is particularly important
|> for <iostream> and <sstream>, where the old header names provide
|> different functionality.
|> When I have to deal with a mixture of behavior in the compilers, I
end
|> up with a mess of #ifdef stuff, and no namespaces.
|
|I just use the old names: <iostream.h>. I've yet to encounter a
|compiler where this didn't work.
It might work but it's not standard. If the following code compiles,
the compiler cannot be called compliant:
#include <iostream.h>
int main() {
cout << "Hello, World!" << endl;
}
|> 2. Non-inline template definitions.
|
|> I want to have the linker instantiate templates whose
implementation
|> is separate from their declaration. This is the only way to
|> break #include dependencies. The code which makes use of a
template
|> should not have to include all of the interfaces used by the
|> implementation of the template.
|
|> Of the compilers with which I have experience, SGI's compiler does
this,
|> while the Metrowerks and MSVC++ compilers do not.
|
| And I'm willing to bet that in this regard, it's VC++ which is
conform,
| and NOT SGI.
Why? Do you think it is right that compilers require template
definitions to be in header files?
Regards,
Sebastian Moleski
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: comeau@panix.com (Greg Comeau)
Date: 2000/06/20 Raw View
In article <8il5lt$1g1f$1@news.nikoma.de>,
Sebastian Moleski <sebmol@gmx.net> wrote:
>If the following code compiles,
>the compiler cannot be called compliant:
>
>#include <iostream.h>
>
>int main() {
> cout << "Hello, World!" << endl;
>}
OF COURSE, that's not so. I'll suspect that you meant something else
and this was a thinko, if not it's worth pointing out that
intuition is often wrong.
- Greg
--
Comeau Computing / Comeau C/C++ 4.2.42 (4.2.44 expected soon)
TRY Comeau C++ ONLINE at http://www.comeaucomputing.com/tryitout
Email: comeau@comeaucomputing.com / WEB: http://www.comeaucomputing.com
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Gillmer J. Derge" <gderge1@nycap.rr.com>
Date: 2000/06/20 Raw View
Scott Meyers wrote:
> On Sun, 18 Jun 2000 08:34:31 CST, Gillmer J. Derge wrote:
> > I would add lack of partial specialization (and thus lack of proper support
> > for traits) and lack of template member functions as two fairly significant
> > problems (for me). Both of these issues are present in Microsoft Visual C++
>
> Can you be more precise about what you want in the way of member templates
> that MSVC fails to offer?
As you surmised, what I want is a proper STL implementation that includes the
various template member functions, such as ctors that take a range defined by
templated iterator arguments. So, yes, in this case my gripe is more with the
library than with the compiler.
-----
Gillmer J. Derge
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Mitch Adler <mitch@intelligentparadigm.com>
Date: 2000/06/20 Raw View
In article <mRV25.71725$nl3.256165@typhoon.ne.mediaone.net>, "David
Abrahams" <abrahams@mediaone.net> wrote:
>I think means that template member functions and classes must be defined
>within the enclosing class body on VC++. I do wonder about GC++ 2.95.5,
>though. At first I thought he was referring to GCC (G++), but that compiler
>is only up to v. 2.95.2. Furthermore, I know that GCC 2.95.2 supports
>out-of-line template member function definitions.
You are correct, on all counts.
I want and explicity tested with a simple case and indeed GCC (2.95.2, I
was incorrect in the orignial version number) supports out of line
template memeber implementations.
GCC can be stricken from the list of problem compilers on that one.
I trust that that Herb will independently verify any claims of
non-conformance through direct testing and not just publish claims
posted here, as many of these claims can be out of date from the current
compiler state.
Mitch
------------------------------------------------------------------------
Mitch Adler "There are people in the world who
Intelligent Paradigm do not love their fellow human beings,
Mitch@mitch.org and I hate people like that."
Mitch@IntelligentParadigm.com - Tom Lehrer
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Francis Glassborow <francis@robinton.demon.co.uk>
Date: 2000/06/20 Raw View
In article <mitch-3E4D27.12400619062000@news.brainstorm.net>, Mitch
Adler <mitch@intelligentparadigm.com> writes
>I trust that that Herb will independently verify any claims of
>non-conformance through direct testing and not just publish claims
>posted here, as many of these claims can be out of date from the current
>compiler state.
OTOH so many people still use earlier versions of a compiler. I recently
audited an excellent C++ Training course that was still using VC++ 5.
The problems had been tackled by the course designer so that what the
delegates used was pretty good C++. However, I was happy to hear the
presenter warn attendees that the compiler was not recommended. I am not
sure that all presenters would have made that message 'loud and clear'.
Francis Glassborow Association of C & C++ Users
64 Southfield Rd
Oxford OX4 1PA +44(0)1865 246490
All opinions are mine and do not represent those of any organisation
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Herb Sutter <hsutter@peerdirect.com>
Date: 2000/06/16 Raw View
Request For Discussion: C++ Compiler/Library Conformance Issues
Posted To: comp.lang.c++
comp.lang.c++.moderated
comp.std.c++
Posted By: Herb Sutter
RFD Opens: June 15, 2000
RFD Closes: June 30, 2000 at 11:59PM EDT
==================================================================
RFD Question:
What compiler/library conformance weaknesses matter to you in
real-world production code?
For example, here are some questions to think about to get you
started. What conformance weaknesses cause you problems:
- because they make you write poorer everyday code (e.g., by
preventing you from using more effective or modern techniques,
or by requiring workarounds that make your code more
complicated and less maintainable)?
- when you move code from one implementation to another?
- when teaching C++ styles or idioms to a less experienced
developer?
- in other situations?
Please be as specific as possible. For example, if one of your
answers is "partial template specialization," what is it about the
lack of support for that feature that causes problems for you?
==================================================================
Overview
--------
I am putting together a roundup of C++ compilers and standard library
implementations. This roundup will focus on standards conformance
only, and will include:
- coverage of the latest shipping versions of all major compilers
and standard library implementations with the active participation
of the vendors;
- a focus on the aspects of conformance that matter most to the
real-world programmer community as represented by Usenet
respondents;
- independent reviews written by major commercial conformance suite
vendors, who have the longest and widest expertise with cross-
platform C++ implementation conformance;
- direct comments on the results by the vendors themselves;
- direct comments on the results by the members of an expert panel,
who include the top names in the industry.
To make sure this roundup is of maximum use to the C++ programming
community, we need your help. Specifically, we need your input about
the areas of standards conformance that matter most to you... hence
this RFD.
Motivation
----------
The principal motivation behind this roundup is to encourage better
product conformance to the C++ standard by shining a bright light on
conformance -- showing which compiler and library implementations
support which parts of the standard well, and rewarding those that
have good overall conformance.
Standards conformance is important because:
a) It benefits users directly. Conformance enables code portability,
and wider consistent use of the C++ language and library.
b) It benefits users indirectly via progressive standards.
Conformance enables continued standards progress. To deliver best
service to the programming community, we the standards committee
must soon consider new and already-popular features, some of which
-- including hash-based containers, smart pointers, ropes, and
typeof -- have substantial existing practice and implementation
experience behind them; such features are important to standardize
sooner rather than later in order to avoid the problems of
widespread proliferation of competing incompatible implementations,
which benefits no one. The major objection I hear to allowing
consideration of new features is that highly-conforming
implementations of the existing standard are not yet widely
available. The wide availability of conforming implementations
will enable the standardizing of existing popular features, which
in turn benefits users.
Goals
-----
This roundup targets the following minimum goals:
a) What: Focus on standards conformance, according to measures that
matter. Many compiler roundups compare compile times, executable
sizes, GUI tool sets, and similar issues. This one will focus
instead on standards conformance. But publishing a checklist of
thousands of tests having equal weighting is unrealistic; the
evaluation endeavors to focus on measures of conformance that
really matter to users (and, for compiler conformance, to standard
library implementers), and the measures must therefore be chosen
with input from the user and implementer community.
b) Why: Encourage progressive conformance. This roundup will
consider only shipping products, but will give each vendor space to
publish their interpretation of results, including remarks about
what improvements they will make available soon. One year later,
the roundup will be repeated, with clear documentation of the new
status quo and a comparative report on who progressed the most in
that time. This will help to encourage and reward vendors'
conformance today, as well as their continued work over the next
year. Vendors with poor conformance results two years running will
be clearly identified.
c) Who: Include all major compiler/library vendors, conformance test
suite vendors, recognized experts, and the voice of the user
community. The main evaluations will be done by two major
conformance test suite vendors, with review by the expert panel.
All major compiler/library vendors will be able to participate
directly during the testing and evaluation process, via restricted
discussion groups set up for the purpose, and will be able to
publish their own views and interpretations as part of the
conformance feature. By soliciting wide input via this newsgroup
RFD, real-world users will be able to say which areas of
conformance matter to them and will therefore be given more weight
in this report; this serves to ensure that the result is as
relevant as possible to real-world programmers.
Conclusion
----------
Your participation in this RFD is important and will matter. Thank
you in advance for in this way contributing to the C++ community, and
I hope you enjoy the result once it is published!
Best regards,
Herb
[ Send an empty e-mail to c++-help@netlab.cs.rpi.edu for info ]
[ about comp.lang.c++.moderated. First time posters: do this! ]
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: "Garth A. Dickie" <Garth_Dickie@avid.com>
Date: 2000/06/17 Raw View
Herb Sutter wrote:
> What compiler/library conformance weaknesses matter to you in
> real-world production code?
I have two favorites:
1. New-style header names, with the standard library in namespace std.
When I write code which is intended to be portable between compilers,
and I want to use the C++ standard library, I would like to use the new
style header names. This is particularly important for <iostream> and
<sstream>, where the old header names provide different functionality.
When I have to deal with a mixture of behavior in the compilers, I end
up with a mess of #ifdef stuff, and no namespaces.
2. Non-inline template definitions.
I want to have the linker instantiate templates whose implementation
is separate from their declaration. This is the only way to
break #include dependencies. The code which makes use of a template
should not have to include all of the interfaces used by the
implementation of the template.
Of the compilers with which I have experience, SGI's compiler does this,
while the Metrowerks and MSVC++ compilers do not.
Regards,
Garth
Sent via Deja.com http://www.deja.com/
Before you buy.
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]