This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/4092: Use of ANSI features in gcc/cp/class.c
- To: gcc-gnats at gcc dot gnu dot org
- Subject: c++/4092: Use of ANSI features in gcc/cp/class.c
- From: rkl at connect dot org dot uk
- Date: 23 Aug 2001 14:04:14 -0000
- Reply-To: rkl at connect dot org dot uk
>Number: 4092
>Category: c++
>Synopsis: Use of ANSI features in gcc/cp/class.c
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Aug 23 07:06:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: rkl@connect.org.uk
>Release: gcc 3.0.1
>Organization:
>Environment:
HP-UX 11.00, but applies to all platforms
>Description:
In gcc/cp/class.c, there's a few places where ANSI C
constructs are used, which prevents the source being
compiled with a K&R compiler (which you do need to do
for this file):
Line 2382 (end of finish_struct_methods() function):
qsort (&TREE_VEC_ELT (method_vec, slot), len-slot, sizeof (tree),
(int (*)(const void *, const void *))method_name_cmp);
(the function prototype for method_name_cmp causes a K&R C
compiler to bomb out)
Line 5463 (middle of finish_struct_1() function):
qsort (&TREE_VEC_ELT (field_vec, 0), n_fields, sizeof (tree),
(int (*)(const void *, const void *))field_decl_cmp);
(same problem as the one above)
Line 4018 (layout_nonempty_base_or_field):
struct record_layout_info_s old_rli = *rli;
(this assignment is illegal in K&R C)
>How-To-Repeat:
Build gcc 3.0.1 with a strictly K&R C compiler - you can
use the "standard" cc in HP-UX (or the HP-UX ANSI C with
CFLAGS="-Ac") to reproduce this. On a side note, it appears
to me that the gcc team don't actually do this - there
are other instances of K&R-illegal code in gcc 3.0.1 as
well (if I get the time, I'll file them, but this bug
should hopefully spark the developers to fix them all).
Not allowing
K&R C compilers to build gcc 3.X is quite poor, IMHO,
especially since you could with 2.95.3.
>Fix:
Conditionalise the statements with "#ifdef __STDC__" - for
example, the first one in my source now reads:
qsort (&TREE_VEC_ELT (method_vec, slot), len-slot, sizeof (tree),
#ifdef __STDC__
(int (*)(const void *, const void *))method_name_cmp);
#else
method_name_cmp);
#endif
>Release-Note:
>Audit-Trail:
>Unformatted: