public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* pr66345.c size_t assumption bug
@ 2015-06-09  2:18 DJ Delorie
  2015-06-09  6:00 ` Marc Glisse
  2015-06-23 19:44 ` Jeff Law
  0 siblings, 2 replies; 4+ messages in thread
From: DJ Delorie @ 2015-06-09  2:18 UTC (permalink / raw)
  To: gcc-patches


The testcase for pr 66345 assumes size_t is "unsigned long" instead of
using the real type, which causes failures on some 16-bit targets.
Ok?

Also, I note that some tests check for __SIZE_TYPE__ as I do below,
and others use it unconditionally as a replacement for size_t.  Is
there a convention?

	* gcc.dg/torture/pr66345.c: Fix assumption about size_t type.
 
 2015-06-08  Tom de Vries  <tom@codesourcery.com>
Index: gcc.dg/torture/pr66345.c
===================================================================
--- gcc.dg/torture/pr66345.c	(revision 224260)
+++ gcc.dg/torture/pr66345.c	(working copy)
@@ -1,9 +1,15 @@
 /* { dg-do compile } */
 
-extern int snprintf (char *, unsigned long, const char *, ...);
+#ifdef __SIZE_TYPE__
+typedef __SIZE_TYPE__ size_t;
+#else
+typedef unsigned int size_t;
+#endif
+
+extern int snprintf (char *, size_t, const char *, ...);
 const char a[] = "";
 int b;
 void
 get_bar ()
 {
   snprintf (0, 0, "%s", &a[b]);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: pr66345.c size_t assumption bug
  2015-06-09  2:18 pr66345.c size_t assumption bug DJ Delorie
@ 2015-06-09  6:00 ` Marc Glisse
  2015-06-23 19:44 ` Jeff Law
  1 sibling, 0 replies; 4+ messages in thread
From: Marc Glisse @ 2015-06-09  6:00 UTC (permalink / raw)
  To: DJ Delorie; +Cc: gcc-patches

On Mon, 8 Jun 2015, DJ Delorie wrote:

> Also, I note that some tests check for __SIZE_TYPE__ as I do below,
> and others use it unconditionally as a replacement for size_t.  Is
> there a convention?

As far as I can tell, __SIZE_TYPE__ is always defined. The tests that 
check for it probably date from a time when it wasn't?

-- 
Marc Glisse

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: pr66345.c size_t assumption bug
  2015-06-09  2:18 pr66345.c size_t assumption bug DJ Delorie
  2015-06-09  6:00 ` Marc Glisse
@ 2015-06-23 19:44 ` Jeff Law
  2015-06-24 22:25   ` DJ Delorie
  1 sibling, 1 reply; 4+ messages in thread
From: Jeff Law @ 2015-06-23 19:44 UTC (permalink / raw)
  To: DJ Delorie, gcc-patches

On 06/08/2015 06:58 PM, DJ Delorie wrote:
> The testcase for pr 66345 assumes size_t is "unsigned long" instead of
> using the real type, which causes failures on some 16-bit targets.
> Ok?

>
> Also, I note that some tests check for __SIZE_TYPE__ as I do below,
> and others use it unconditionally as a replacement for size_t.  Is
> there a convention?
I doubt there's a well defined convention.  Particularly for the torture 
tests, many of which are very very old.

>
> 	* gcc.dg/torture/pr66345.c: Fix assumption about size_t type.
OK.

jeff


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: pr66345.c size_t assumption bug
  2015-06-23 19:44 ` Jeff Law
@ 2015-06-24 22:25   ` DJ Delorie
  0 siblings, 0 replies; 4+ messages in thread
From: DJ Delorie @ 2015-06-24 22:25 UTC (permalink / raw)
  To: Jeff Law; +Cc: gcc-patches


> OK.

Thanks, committed.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-06-24 21:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-09  2:18 pr66345.c size_t assumption bug DJ Delorie
2015-06-09  6:00 ` Marc Glisse
2015-06-23 19:44 ` Jeff Law
2015-06-24 22:25   ` DJ Delorie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).