* [commit] Properly cast sentinels for concat()
@ 2005-07-04 13:36 Mark Kettenis
2005-07-04 22:08 ` Eli Zaretskii
0 siblings, 1 reply; 9+ messages in thread
From: Mark Kettenis @ 2005-07-04 13:36 UTC (permalink / raw)
To: gdb-patches
This fixes a few warnings with GCC 4.0 on OpenBSD. You'll probably
won't see them on other systems, since they only show up if NULL is
defined as an integer instead of a pointer constant (both are valid
according to C standard). The stddef.h that comes with GCC defines
NULL as (void *)NULL, but we don't use that one on OpenBSD.
Anyway, I committed the attached patch as obvious.
Index: ChangeLog
from Mark Kettenis <kettenis@gnu.org>
* bsd-kvm.c (bsd_kvm_open): Properly cast sentinel in concat call.
* coffread.c (patch_type, process_coff_symbol): Likewise.
* corelow.c (core_open): Likewise.
* dwarf2read.c (dwarf_decode_lines, dwarf2_start_subfile):
* language.c (set_lang_str, set_type_str, set_range_str)
(set_case_str): Likewise.
* source.c (add_path, openp): Likewise.
* stabsread.c: Likewise.
* top.c (init_history): Likewise.
* utils.c (xfullpath): Likewise.
* value.c (lookup_internalvar): Likewise.
* cli/cli-cmds.c (cd_command): Likewise.
* cli/cli-dump.c (add_dump_command): Likewise.
Index: bsd-kvm.c
===================================================================
RCS file: /cvs/src/src/gdb/bsd-kvm.c,v
retrieving revision 1.13
diff -u -p -r1.13 bsd-kvm.c
--- bsd-kvm.c 16 May 2005 16:36:23 -0000 1.13
+++ bsd-kvm.c 4 Jul 2005 13:26:39 -0000
@@ -70,7 +70,7 @@ bsd_kvm_open (char *filename, int from_t
filename = tilde_expand (filename);
if (filename[0] != '/')
{
- temp = concat (current_directory, "/", filename, NULL);
+ temp = concat (current_directory, "/", filename, (char *)NULL);
xfree (filename);
filename = temp;
}
Index: coffread.c
===================================================================
RCS file: /cvs/src/src/gdb/coffread.c,v
retrieving revision 1.61
diff -u -p -r1.61 coffread.c
--- coffread.c 11 Feb 2005 04:05:45 -0000 1.61
+++ coffread.c 4 Jul 2005 13:26:39 -0000
@@ -1,6 +1,6 @@
/* Read coff symbol tables and convert to internal format, for GDB.
Copyright 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
- 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+ 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
Contributed by David D. Johnson, Brown University (ddj@cs.brown.edu).
@@ -1399,7 +1399,7 @@ patch_type (struct type *type, struct ty
{
if (TYPE_NAME (target))
xfree (TYPE_NAME (target));
- TYPE_NAME (target) = concat (TYPE_NAME (real_target), NULL);
+ TYPE_NAME (target) = concat (TYPE_NAME (real_target), (char *)NULL);
}
}
@@ -1636,7 +1636,7 @@ process_coff_symbol (struct coff_symbol
}
else
TYPE_NAME (SYMBOL_TYPE (sym)) =
- concat (DEPRECATED_SYMBOL_NAME (sym), NULL);
+ concat (DEPRECATED_SYMBOL_NAME (sym), (char *)NULL);
}
/* Keep track of any type which points to empty structured type,
@@ -1671,7 +1671,7 @@ process_coff_symbol (struct coff_symbol
&& *DEPRECATED_SYMBOL_NAME (sym) != '~'
&& *DEPRECATED_SYMBOL_NAME (sym) != '.')
TYPE_TAG_NAME (SYMBOL_TYPE (sym)) =
- concat (DEPRECATED_SYMBOL_NAME (sym), NULL);
+ concat (DEPRECATED_SYMBOL_NAME (sym), (char *)NULL);
add_symbol_to_list (sym, &file_symbols);
break;
Index: corelow.c
===================================================================
RCS file: /cvs/src/src/gdb/corelow.c,v
retrieving revision 1.51
diff -u -p -r1.51 corelow.c
--- corelow.c 13 Jun 2005 18:39:11 -0000 1.51
+++ corelow.c 4 Jul 2005 13:26:39 -0000
@@ -300,7 +300,7 @@ core_open (char *filename, int from_tty)
filename = tilde_expand (filename);
if (filename[0] != '/')
{
- temp = concat (current_directory, "/", filename, NULL);
+ temp = concat (current_directory, "/", filename, (char *)NULL);
xfree (filename);
filename = temp;
}
Index: dwarf2read.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2read.c,v
retrieving revision 1.181
diff -u -p -r1.181 dwarf2read.c
--- dwarf2read.c 9 Mar 2005 06:03:14 -0000 1.181
+++ dwarf2read.c 4 Jul 2005 13:26:41 -0000
@@ -1,7 +1,7 @@
/* DWARF 2 debugging format support for GDB.
Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
- 2004
+ 2004, 2005
Free Software Foundation, Inc.
Adapted by Gary Funck (gary@intrepid.com), Intrepid Technology,
@@ -6632,15 +6632,15 @@ dwarf_decode_lines (struct line_header *
if (!IS_ABSOLUTE_PATH (include_name) && dir_name != NULL)
{
- include_name =
- concat (dir_name, SLASH_STRING, include_name, NULL);
+ include_name = concat (dir_name, SLASH_STRING,
+ include_name, (char *)NULL);
make_cleanup (xfree, include_name);
}
if (!IS_ABSOLUTE_PATH (pst_filename) && pst->dirname != NULL)
{
- pst_filename =
- concat (pst->dirname, SLASH_STRING, pst_filename, NULL);
+ pst_filename = concat (pst->dirname, SLASH_STRING,
+ pst_filename, (char *)NULL);
make_cleanup (xfree, pst_filename);
}
@@ -6679,7 +6679,7 @@ dwarf2_start_subfile (char *filename, ch
if (!IS_ABSOLUTE_PATH (filename) && dirname != NULL)
{
struct subfile *subfile;
- char *fullname = concat (dirname, "/", filename, NULL);
+ char *fullname = concat (dirname, "/", filename, (char *)NULL);
for (subfile = subfiles; subfile; subfile = subfile->next)
{
Index: language.c
===================================================================
RCS file: /cvs/src/src/gdb/language.c,v
retrieving revision 1.60
diff -u -p -r1.60 language.c
--- language.c 9 May 2005 21:20:34 -0000 1.60
+++ language.c 4 Jul 2005 13:26:42 -0000
@@ -412,7 +412,7 @@ set_lang_str (void)
if (language_mode == language_mode_auto)
prefix = "auto; currently ";
- language = concat (prefix, current_language->la_name, NULL);
+ language = concat (prefix, current_language->la_name, (char *)NULL);
}
static void
@@ -440,7 +440,7 @@ set_type_str (void)
error (_("Unrecognized type check setting."));
}
- type = concat (prefix, tmp, NULL);
+ type = concat (prefix, tmp, (char *)NULL);
}
static void
@@ -468,7 +468,7 @@ set_range_str (void)
if (range)
xfree (range);
- range = concat (pref, tmp, NULL);
+ range = concat (pref, tmp, (char *)NULL);
}
static void
@@ -492,7 +492,7 @@ set_case_str (void)
}
xfree (case_sensitive);
- case_sensitive = concat (prefix, tmp, NULL);
+ case_sensitive = concat (prefix, tmp, (char *)NULL);
}
/* Print out the current language settings: language, range and
Index: source.c
===================================================================
RCS file: /cvs/src/src/gdb/source.c,v
retrieving revision 1.68
diff -u -p -r1.68 source.c
--- source.c 27 May 2005 04:39:32 -0000 1.68
+++ source.c 4 Jul 2005 13:26:42 -0000
@@ -1,6 +1,6 @@
/* List lines of source files for GDB, the GNU debugger.
Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
- 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
+ 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc.
This file is part of GDB.
@@ -487,10 +487,10 @@ add_path (char *dirname, char **which_pa
name = tilde_expand (name);
#ifdef HAVE_DOS_BASED_FILE_SYSTEM
else if (IS_ABSOLUTE_PATH (name) && p == name + 2) /* "d:" => "d:." */
- name = concat (name, ".", NULL);
+ name = concat (name, ".", (char *)NULL);
#endif
else if (!IS_ABSOLUTE_PATH (name) && name[0] != '$')
- name = concat (current_directory, SLASH_STRING, name, NULL);
+ name = concat (current_directory, SLASH_STRING, name, (char *)NULL);
else
name = savestring (name, p - name);
make_cleanup (xfree, name);
@@ -563,15 +563,16 @@ add_path (char *dirname, char **which_pa
c = old[prefix];
old[prefix] = '\0';
- temp = concat (old, tinybuf, name, NULL);
+ temp = concat (old, tinybuf, name, (char *)NULL);
old[prefix] = c;
- *which_path = concat (temp, "", &old[prefix], NULL);
+ *which_path = concat (temp, "", &old[prefix], (char *)NULL);
prefix = strlen (temp);
xfree (temp);
}
else
{
- *which_path = concat (name, (old[0] ? tinybuf : old), old, NULL);
+ *which_path = concat (name, (old[0] ? tinybuf : old),
+ old, (char *)NULL);
prefix = strlen (name);
}
xfree (old);
@@ -771,7 +772,7 @@ done:
char *f = concat (current_directory,
IS_DIR_SEPARATOR (current_directory[strlen (current_directory) - 1])
? "" : SLASH_STRING,
- filename, NULL);
+ filename, (char *)NULL);
*filename_opened = xfullpath (f);
xfree (f);
}
Index: stabsread.c
===================================================================
RCS file: /cvs/src/src/gdb/stabsread.c,v
retrieving revision 1.80
diff -u -p -r1.80 stabsread.c
--- stabsread.c 11 Feb 2005 18:13:53 -0000 1.80
+++ stabsread.c 4 Jul 2005 13:26:43 -0000
@@ -1,8 +1,8 @@
/* Support routines for decoding "stabs" debugging information format.
Copyright 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
- 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free
- Software Foundation, Inc.
+ 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+ Free Software Foundation, Inc.
This file is part of GDB.
@@ -2527,7 +2527,8 @@ read_member_functions (struct field_info
}
else if (has_destructor && new_fnlist->fn_fieldlist.name[0] != '~')
{
- new_fnlist->fn_fieldlist.name = concat ("~", main_fn_name, NULL);
+ new_fnlist->fn_fieldlist.name =
+ concat ("~", main_fn_name, (char *)NULL);
xfree (main_fn_name);
}
else if (!has_stub)
Index: top.c
===================================================================
RCS file: /cvs/src/src/gdb/top.c,v
retrieving revision 1.104
diff -u -p -r1.104 top.c
--- top.c 12 May 2005 21:23:17 -0000 1.104
+++ top.c 4 Jul 2005 13:26:43 -0000
@@ -1370,9 +1370,11 @@ init_history (void)
that was read. */
#ifdef __MSDOS__
/* No leading dots in file names are allowed on MSDOS. */
- history_filename = concat (current_directory, "/_gdb_history", NULL);
+ history_filename = concat (current_directory, "/_gdb_history",
+ (char *)NULL);
#else
- history_filename = concat (current_directory, "/.gdb_history", NULL);
+ history_filename = concat (current_directory, "/.gdb_history",
+ (char *)NULL);
#endif
}
read_history (history_filename);
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.160
diff -u -p -r1.160 utils.c
--- utils.c 18 Mar 2005 20:46:38 -0000 1.160
+++ utils.c 4 Jul 2005 13:26:44 -0000
@@ -3030,9 +3030,9 @@ xfullpath (const char *filename)
directory separator, avoid doubling it. */
real_path = gdb_realpath (dir_name);
if (IS_DIR_SEPARATOR (real_path[strlen (real_path) - 1]))
- result = concat (real_path, base_name, NULL);
+ result = concat (real_path, base_name, (char *)NULL);
else
- result = concat (real_path, SLASH_STRING, base_name, NULL);
+ result = concat (real_path, SLASH_STRING, base_name, (char *)NULL);
xfree (real_path);
return result;
Index: value.c
===================================================================
RCS file: /cvs/src/src/gdb/value.c,v
retrieving revision 1.29
diff -u -p -r1.29 value.c
--- value.c 9 May 2005 21:20:35 -0000 1.29
+++ value.c 4 Jul 2005 13:26:44 -0000
@@ -743,7 +743,7 @@ lookup_internalvar (char *name)
return var;
var = (struct internalvar *) xmalloc (sizeof (struct internalvar));
- var->name = concat (name, NULL);
+ var->name = concat (name, (char *)NULL);
var->value = allocate_value (builtin_type_void);
release_value (var->value);
var->next = internalvars;
Index: cli/cli-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-cmds.c,v
retrieving revision 1.61
diff -u -p -r1.61 cli-cmds.c
--- cli/cli-cmds.c 27 May 2005 04:39:33 -0000 1.61
+++ cli/cli-cmds.c 4 Jul 2005 13:26:45 -0000
@@ -366,9 +366,10 @@ cd_command (char *dir, int from_tty)
else
{
if (IS_DIR_SEPARATOR (current_directory[strlen (current_directory) - 1]))
- current_directory = concat (current_directory, dir, NULL);
+ current_directory = concat (current_directory, dir, (char *)NULL);
else
- current_directory = concat (current_directory, SLASH_STRING, dir, NULL);
+ current_directory = concat (current_directory, SLASH_STRING,
+ dir, (char *)NULL);
xfree (dir);
}
Index: cli/cli-dump.c
===================================================================
RCS file: /cvs/src/src/gdb/cli/cli-dump.c,v
retrieving revision 1.22
diff -u -p -r1.22 cli-dump.c
--- cli/cli-dump.c 26 May 2005 20:49:03 -0000 1.22
+++ cli/cli-dump.c 4 Jul 2005 13:26:45 -0000
@@ -438,7 +438,7 @@ add_dump_command (char *name, void (*fun
&& c->doc[3] == 't'
&& c->doc[4] == 'e'
&& c->doc[5] == ' ')
- c->doc = concat ("Append ", c->doc + 6, NULL);
+ c->doc = concat ("Append ", c->doc + 6, (char *)NULL);
}
/* Opaque data for restore_section_callback. */
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [commit] Properly cast sentinels for concat()
2005-07-04 13:36 [commit] Properly cast sentinels for concat() Mark Kettenis
@ 2005-07-04 22:08 ` Eli Zaretskii
2005-07-04 23:16 ` Andreas Schwab
` (2 more replies)
0 siblings, 3 replies; 9+ messages in thread
From: Eli Zaretskii @ 2005-07-04 22:08 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
> Date: Mon, 4 Jul 2005 15:36:05 +0200
> From: Mark Kettenis <kettenis@jive.nl>
>
> This fixes a few warnings with GCC 4.0 on OpenBSD. You'll probably
> won't see them on other systems, since they only show up if NULL is
> defined as an integer instead of a pointer constant (both are valid
> according to C standard). The stddef.h that comes with GCC defines
> NULL as (void *)NULL, but we don't use that one on OpenBSD.
>
> Anyway, I committed the attached patch as obvious.
Actually, it's not at all obvious, it's IMNSHO simply wrong. Casting
NULL to _anything_ should never be needed, unless NULL is abused
(i.e. used in a place where a pointer cannot be). Let's not decide
that a patch is ``obvious'' just because it happens to shut up the
compiler!
In this case, I'd say it's a bug in OpenBSD (it _should_ use stddef.h
that comes with GCC when a program is compiled with GCC), coupled with
the silly attitude of latest GCC versions to whine about more and more
perfectly valid C code constructs.
Since these are warnings, I urge you to undo the ugly casts, and
instead ask the maintainers of the OpenBSD port of GCC to arrange for
the right stddef.h to be used. With any luck, this will be fixed in
GCC 4.01 or some such, and until then let there be warnings on
OpenBSD.
(FWIW, in DJGPP we went through the same ordeal a few years ago, and
the solution was simple: let GCC use its stddef.h, and define NULL in
our own headers conditionally on it still being undefined.)
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [commit] Properly cast sentinels for concat()
2005-07-04 22:08 ` Eli Zaretskii
@ 2005-07-04 23:16 ` Andreas Schwab
2005-07-05 1:32 ` Daniel Jacobowitz
2005-07-05 7:36 ` Mark Kettenis
2 siblings, 0 replies; 9+ messages in thread
From: Andreas Schwab @ 2005-07-04 23:16 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Mark Kettenis, gdb-patches
Eli Zaretskii <eliz@gnu.org> writes:
> In this case, I'd say it's a bug in OpenBSD (it _should_ use stddef.h
> that comes with GCC when a program is compiled with GCC), coupled with
> the silly attitude of latest GCC versions to whine about more and more
> perfectly valid C code constructs.
Passing NULL as a vararg parameter is _not_ perfectly valid.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, MaxfeldstraÃe 5, 90409 Nürnberg, Germany
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [commit] Properly cast sentinels for concat()
2005-07-04 22:08 ` Eli Zaretskii
2005-07-04 23:16 ` Andreas Schwab
@ 2005-07-05 1:32 ` Daniel Jacobowitz
2005-07-05 3:34 ` Eli Zaretskii
2005-07-05 7:36 ` Mark Kettenis
2 siblings, 1 reply; 9+ messages in thread
From: Daniel Jacobowitz @ 2005-07-05 1:32 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: Mark Kettenis, gdb-patches
On Tue, Jul 05, 2005 at 01:08:22AM +0200, Eli Zaretskii wrote:
> > Date: Mon, 4 Jul 2005 15:36:05 +0200
> > From: Mark Kettenis <kettenis@jive.nl>
> >
> > This fixes a few warnings with GCC 4.0 on OpenBSD. You'll probably
> > won't see them on other systems, since they only show up if NULL is
> > defined as an integer instead of a pointer constant (both are valid
> > according to C standard). The stddef.h that comes with GCC defines
> > NULL as (void *)NULL, but we don't use that one on OpenBSD.
> >
> > Anyway, I committed the attached patch as obvious.
>
> Actually, it's not at all obvious, it's IMNSHO simply wrong. Casting
> NULL to _anything_ should never be needed, unless NULL is abused
> (i.e. used in a place where a pointer cannot be). Let's not decide
> that a patch is ``obvious'' just because it happens to shut up the
> compiler!
You must cast NULL to a pointer type if you use it as the sentinel in a
varargs list, in portable code, because 0 is a legal definition of NULL
(according to the C standard, which is quite clear on the subject). On
an I32 LP64 system, passing 0 to a varargs function may take 32 bits on
the stack while passing NULL takes 64 bits. If you pass the wrong one,
you'll wander up the stack to nowhere.
This is often called "the execl bug", because execl is the most
frequently used function in the standard library which takes NULL as a
terminator for a list of string constants.
Even more C++ implementations use 0, which makes the problem even
worse. ISTR that (void *)0 is not an acceptable definition of NULL in
C++.
--
Daniel Jacobowitz
CodeSourcery, LLC
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [commit] Properly cast sentinels for concat()
2005-07-05 1:32 ` Daniel Jacobowitz
@ 2005-07-05 3:34 ` Eli Zaretskii
2005-07-05 4:23 ` Daniel Jacobowitz
2005-07-05 7:30 ` Mark Kettenis
0 siblings, 2 replies; 9+ messages in thread
From: Eli Zaretskii @ 2005-07-05 3:34 UTC (permalink / raw)
To: Mark Kettenis, gdb-patches
> Date: Mon, 4 Jul 2005 18:51:53 -0400
> From: Daniel Jacobowitz <drow@false.org>
> Cc: Mark Kettenis <kettenis@jive.nl>, gdb-patches@sourceware.org
>
> You must cast NULL to a pointer type if you use it as the sentinel in a
> varargs list, in portable code, because 0 is a legal definition of NULL
> (according to the C standard, which is quite clear on the subject). On
> an I32 LP64 system, passing 0 to a varargs function may take 32 bits on
> the stack while passing NULL takes 64 bits.
But in Mark's case, NULL is defined as (void *)0, so it's a pointer,
not an int.
> Even more C++ implementations use 0, which makes the problem even
> worse. ISTR that (void *)0 is not an acceptable definition of NULL in
> C++.
We are not talking about C++ code here, nor about a C++ compiler.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [commit] Properly cast sentinels for concat()
2005-07-05 3:34 ` Eli Zaretskii
@ 2005-07-05 4:23 ` Daniel Jacobowitz
2005-07-05 7:30 ` Mark Kettenis
1 sibling, 0 replies; 9+ messages in thread
From: Daniel Jacobowitz @ 2005-07-05 4:23 UTC (permalink / raw)
To: gdb-patches
On Tue, Jul 05, 2005 at 06:34:18AM +0200, Eli Zaretskii wrote:
> > Date: Mon, 4 Jul 2005 18:51:53 -0400
> > From: Daniel Jacobowitz <drow@false.org>
> > Cc: Mark Kettenis <kettenis@jive.nl>, gdb-patches@sourceware.org
> >
> > You must cast NULL to a pointer type if you use it as the sentinel in a
> > varargs list, in portable code, because 0 is a legal definition of NULL
> > (according to the C standard, which is quite clear on the subject). On
> > an I32 LP64 system, passing 0 to a varargs function may take 32 bits on
> > the stack while passing NULL takes 64 bits.
>
> But in Mark's case, NULL is defined as (void *)0, so it's a pointer,
> not an int.
No, OpenBSD uses 0 rather than (void *) 0. As the language allows.
--
Daniel Jacobowitz
CodeSourcery, LLC
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [commit] Properly cast sentinels for concat()
2005-07-05 3:34 ` Eli Zaretskii
2005-07-05 4:23 ` Daniel Jacobowitz
@ 2005-07-05 7:30 ` Mark Kettenis
2005-07-05 20:03 ` Eli Zaretskii
1 sibling, 1 reply; 9+ messages in thread
From: Mark Kettenis @ 2005-07-05 7:30 UTC (permalink / raw)
To: eliz; +Cc: gdb-patches
Date: Tue, 05 Jul 2005 06:34:18 +0200
From: Eli Zaretskii <eliz@gnu.org>
> Date: Mon, 4 Jul 2005 18:51:53 -0400
> From: Daniel Jacobowitz <drow@false.org>
> Cc: Mark Kettenis <kettenis@jive.nl>, gdb-patches@sourceware.org
>
> You must cast NULL to a pointer type if you use it as the sentinel in a
> varargs list, in portable code, because 0 is a legal definition of NULL
> (according to the C standard, which is quite clear on the subject). On
> an I32 LP64 system, passing 0 to a varargs function may take 32 bits on
> the stack while passing NULL takes 64 bits.
But in Mark's case, NULL is defined as (void *)0, so it's a pointer,
not an int.
No it isn't, OpenBSD has
#define NULL 0L
which incidentally has the nice property that it makes GCC warn about
a potential problem with the code without actually having that problem
on any OpenBSD platform (which are either ILP32 or LP64). This
defenition would expose the bug Daniel describes on IL32 P64 platforms
(64-bit Windows, HP-UX on Itanium).
> Even more C++ implementations use 0, which makes the problem even
> worse. ISTR that (void *)0 is not an acceptable definition of NULL in
> C++.
We are not talking about C++ code here, nor about a C++ compiler.
Not that I think that it is a good thing, but Andrew has been talking
about making GDB compilable with a C++ compiler before.
Do you still want me to revert the patch?
Mark
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [commit] Properly cast sentinels for concat()
2005-07-05 7:30 ` Mark Kettenis
@ 2005-07-05 20:03 ` Eli Zaretskii
0 siblings, 0 replies; 9+ messages in thread
From: Eli Zaretskii @ 2005-07-05 20:03 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches
> Date: Tue, 5 Jul 2005 09:28:56 +0200
> From: Mark Kettenis <kettenis@jive.nl>
> CC: gdb-patches@sourceware.org
>
> But in Mark's case, NULL is defined as (void *)0, so it's a pointer,
> not an int.
>
> No it isn't, OpenBSD has
>
> #define NULL 0L
Sorry, I got confused: you did mention `void *', but that was about
the GCC version of stddef.h.
> Not that I think that it is a good thing, but Andrew has been talking
> about making GDB compilable with a C++ compiler before.
I never understood why we should waste any efforts on that.
> Do you still want me to revert the patch?
Well, let's say that I dislike those casts very much. So if there's
any reasonable chance to get the maintainers of OpenBSD and the
OpenBSD GCC port to fix this problem in the forseeble future, I'd
suggest to revert it. If not, I'll yield.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [commit] Properly cast sentinels for concat()
2005-07-04 22:08 ` Eli Zaretskii
2005-07-04 23:16 ` Andreas Schwab
2005-07-05 1:32 ` Daniel Jacobowitz
@ 2005-07-05 7:36 ` Mark Kettenis
2 siblings, 0 replies; 9+ messages in thread
From: Mark Kettenis @ 2005-07-05 7:36 UTC (permalink / raw)
To: eliz; +Cc: gdb-patches
Date: Tue, 05 Jul 2005 01:08:22 +0200
From: Eli Zaretskii <eliz@gnu.org>
CC: gdb-patches@sourceware.org
Reply-to: Eli Zaretskii <eliz@gnu.org>
> Date: Mon, 4 Jul 2005 15:36:05 +0200
> From: Mark Kettenis <kettenis@jive.nl>
>
> This fixes a few warnings with GCC 4.0 on OpenBSD. You'll probably
> won't see them on other systems, since they only show up if NULL is
> defined as an integer instead of a pointer constant (both are valid
> according to C standard). The stddef.h that comes with GCC defines
> NULL as (void *)NULL, but we don't use that one on OpenBSD.
>
> Anyway, I committed the attached patch as obvious.
Actually, it's not at all obvious,
Apparently not :(.
it's IMNSHO simply wrong. Casting
NULL to _anything_ should never be needed, unless NULL is abused
(i.e. used in a place where a pointer cannot be). Let's not decide
that a patch is ``obvious'' just because it happens to shut up the
compiler!
Unfortuntaly, as Daniel excellently explained, this isn't just to shut
up the compiler.
In this case, I'd say it's a bug in OpenBSD (it _should_ use stddef.h
that comes with GCC when a program is compiled with GCC), coupled with
the silly attitude of latest GCC versions to whine about more and more
perfectly valid C code constructs.
Let's not argue about these points. There are arguments for both
sides here. But the fact is that OpenBSD does provide it's own
stddef.h, so we have to deal with it.
Mark
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2005-07-05 20:03 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-04 13:36 [commit] Properly cast sentinels for concat() Mark Kettenis
2005-07-04 22:08 ` Eli Zaretskii
2005-07-04 23:16 ` Andreas Schwab
2005-07-05 1:32 ` Daniel Jacobowitz
2005-07-05 3:34 ` Eli Zaretskii
2005-07-05 4:23 ` Daniel Jacobowitz
2005-07-05 7:30 ` Mark Kettenis
2005-07-05 20:03 ` Eli Zaretskii
2005-07-05 7:36 ` Mark Kettenis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox