Will C++ proponents spend 20 minutes to try what they're proposing?

John Gilmore gnu@toad.com
Wed Apr 18 19:18:00 GMT 2012


Jan Kratochvil said:
> I can't believe we do not agree on such basic way forward.

Changing the implementation language of a huge program, more than
twenty years after its creation, is not "basic".

Has any of the proponents even *tried* to compile and run today's GDB
using a C++ compiler, to see what C constructs that it currently uses
will be rejected by the C++ compiler?  "./configure CC=g++; make check", or
something similar, should do most of that for you.

Recompiling the C code in C++ is the approach you're proposing to
take, right?  Or do you propose that we compile some source files with
a C compiler and others with a C++ compiler?

If it will compile easily with a C++ compiler, then you could start
migrating small bits of it here and there to C++.  If it won't compile
easily, then there's a more substantial hurdle to cross before even a
line of new C++ code could be written.  Ideally if we were going to
switch to C++, we'd migrate the current code base so that it would
compile with either C or C++.  Then and only then would we commit
ourselves by writing new C++ code, knowing that we still have a
working debugger.

When I configure gdb-7.4 with C++ and make it, it fails pretty early
here in libiberty:

./cplus-dem.c: In function ‘void demangle_arm_hp_template(work_stuff*, const char**, int, string*)’:
./cplus-dem.c:2351:46: error: invalid conversion from ‘const char*’ to ‘char*’

(I'm amused that the C++ demangler is the first C function to fail.)

I've appended a bunch of other errors that turn up from "make -i".
There are MANY more, and I didn't scan beyond the "f"s in BFD.  (The
GDB source files themselves also get a ton of errors).  Yes, I realize
many of these are simple fixes.  Perhaps a proponent should make these
fixes.  Some of them bother me, e.g. "deprecated string constant
conversion to char *".  C code regularly uses strings with char *'s.
Is this a foolish hobgoblin of const-correctness?

PS:  When did g++ start outputting non-ascii (Unicode) backquotes
and forward-quotes in its error messages?  That's truly ugly.  Look
at the compiler output in Emacs, for example.

	John

./md5.c: In function ‘void* md5_finish_ctx(md5_ctx*, void*)’:
./md5.c:117:43: warning: dereferencing type-punned pointer will break strict-aliasing rules
./md5.c:118:47: warning: dereferencing type-punned pointer will break strict-aliasing rules

./alloca.c: In function ‘void* C_alloca(size_t)’:
./alloca.c:164:3: warning: ‘auto’ will change meaning in C++0x; please remove it

./floatformat.c:22:0: warning: "_GNU_SOURCE" redefined
<command-line>:0:0: note: this is the location of the previous definition

./stack-limit.c:52:27: warning: use of C++0x long long integer constant
./stack-limit.c:54:28: warning: use of C++0x long long integer constant
./stack-limit.c:57:28: warning: use of C++0x long long integer constant

In file included from archive.c:131:0:
bfd.h:6246:31: error: ‘bfd_boolean bfd_section_already_linked(bfd*, asection*, bfd_link_info*)’ hides constructor for ‘struct bfd_section_already_linked’
In file included from archive.c:132:0:
./../include/libiberty.h:110:36: error: new declaration ‘char* basename(const char*)’
/usr/include/string.h:603:28: error: ambiguates old declaration ‘const char* basename(const char*)’
archive.c: In function ‘bfd_boolean _bfd_write_archive_contents(bfd*)’:
archive.c:2115:11: error: deprecated conversion from string constant to ‘char*’
archive.c:2117:13: error: deprecated conversion from string constant to ‘char*’
In file included from bfd.c:319:0:

cache.c: In function ‘void* cache_bmmap(bfd*, void*, bfd_size_type, int, int, file_ptr, void**, bfd_size_type*)’:
cache.c:440:27: error: pointer of type ‘void *’ used in arithmetic

srec.c:1324:1: error: deprecated conversion from string constant to ‘char*’
srec.c:1380:1: error: deprecated conversion from string constant to ‘char*’

binary.c: In function ‘char* mangle_name(bfd*, char*)’:
binary.c:135:12: error: deprecated conversion from string constant to ‘char*’
binary.c: In function ‘long int binary_canonicalize_symtab(bfd*, asymbol**)’:
binary.c:163:44: error: deprecated conversion from string constant to ‘char*’
binary.c:171:42: error: deprecated conversion from string constant to ‘char*’
binary.c:179:43: error: deprecated conversion from string constant to ‘char*’
binary.c: At global scope:
binary.c:369:1: error: deprecated conversion from string constant to ‘char*’

tekhex.c:1016:1: error: deprecated conversion from string constant to ‘char*’

./dwarf2.c: In function ‘int compare_sequences(const void*, const void*)’:
./dwarf2.c:1299:38: error: invalid conversion from ‘const void*’ to ‘const line_sequence*’
./dwarf2.c:1300:38: error: invalid conversion from ‘const void*’ to ‘const line_sequence*’

elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c:185:1: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c: In function ‘bfd_boolean elf_i386_grok_prstatus(bfd*, Elf_Internal_Note*)’:
elf32-i386.c:454:36: error: deprecated conversion from string constant to ‘char*’
elf32-i386.c: In function ‘bfd_boolean elf_i386_create_dynamic_sections(bfd*, bfd_link_info*)’:
elf32-i386.c:1030:47: error: invalid conversion from ‘void*’ to ‘unsigned char*’
In file included from elf32-i386.c:4989:0:
elf32-target.h: At global scope:
elf32-target.h:987:1: error: deprecated conversion from string constant to ‘char*’
In file included from elf32-i386.c:5022:0:
elf32-target.h:987:1: error: deprecated conversion from string constant to ‘char*’
In file included from elf32-i386.c:5050:0:
elf32-target.h:987:1: error: deprecated conversion from string constant to ‘char*’
In file included from elf32-i386.c:5214:0:
elf32-target.h:987:1: error: deprecated conversion from string constant to ‘char*’
In file included from elf32-i386.c:5259:0:
elf32-target.h:987:1: error: deprecated conversion from string constant to ‘char*’



More information about the Gdb mailing list