From: James Kuyper on
I'm a very competent and experienced C programmer, with a pretty good
understanding of C++98. I haven't kept up very well on the changes that
have been made since C++98, but for the code I'm talking about, C++98 is
the relevant standard. I used to participate frequently in comp.std.c++,
(literally thousands of posts). However, I've done very little actual
programming in C++, but not recently, and none of it in a professional
context, and that lack of experience has suddenly become important.

I now need to adapt some C++ code written by someone else, to work in
our environment. The relevant requirements are that it must work
correctly on this computer:

~(43) uname -a
IRIX64 modular 6.5 10070055 IP35

using this compiler:
~(44) /usr/freeware/bin/g++ --version
g++ (GCC) 3.3

And on this computer:
~(101) uname -a
Linux moddev5 2.6.8.1-12mdksmp #1 SMP Fri Oct 1 11:24:45 CEST 2004 i686
Intel(R) Xeon(TM) CPU 2.80GHz unknown GNU/Linux

using this compiler:
~(102) g++ --version
g++ (GCC) 3.4.1 (Mandrakelinux 10.1 3.4.1-4mdk)

I may be able to convince the Sysadmins to upgrade those versions, but
they are very busy, and we do very little C++ development (none before
today), so they might refuse. Assume, for the worst case analysis, that
they will.

I'm very familiar with the portability issues between those two machines
for C code. I would expect the issues are pretty much the same for C++.
Is that correct?

In addition, as defined by the C++98 standard, the program should have
no syntax errors or constraint violations, and to the greatest extent
possible it should not rely upon any undefined or implementation-defined
behavior. The only unportable assumptions the code needs to make are
8-bit bytes and US ASCII character encoding. It can also assume POSIX,
but I don't think it needs to.

I have two questions:

1. Which set of options makes those versions of that compiler come
closest to fully conforming to the C++98 standard?

My current best guess is:

-std=c++98
-pedantic
-Wall
-Wpointer-arith
-Wcast-align
-fno-enforce-eh-specs
-ffor-scope
-fno-gnu-keywords
-fno-nonansi-builtins
-Wctor-dtor-privacy
-Wnon-virtual-dtor
-Wold-style-cast
-Woverloaded-virtual
-Wsign-promo

With those options, from 30K LOC, I get 48 warnings about comparing
signed and unsigned values, three unused variables, and dozens of
warnings about old-style casts. That's pretty clean code, judging from
my prior experience with porting other people's C code.


2. I own a perfectly legal copy of C++98 standard, which is currently
stuck on a hard drive that is inaccessible due to hardware failure and
software installation problems. If I had more practical C++ experience,
that wouldn't matter, but to fix those old-style cast problems, I need
to reference the standard, or a good substitute for the standard. What
is the closest substitute to that version of the standard, that I could
get access to for free today (which basically means it has to be
something online)?

--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]