GNU bug report logs -
#12753
printf in make-prime-list.c uses "modern" features
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 12753 in the body.
You can then email your comments to 12753 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-coreutils <at> gnu.org
:
bug#12753
; Package
coreutils
.
(Sun, 28 Oct 2012 19:43:03 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
John David Anglin <dave.anglin <at> nrc-cnrc.gc.ca>
:
New bug report received and forwarded. Copy sent to
bug-coreutils <at> gnu.org
.
(Sun, 28 Oct 2012 19:43:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
make-prime-list crashes on hppa1.1-hp-hpux10.20. This probably
will occur on any hppa-hpux system.
Attached is a hack to work around the problem.
Dave
--
J. David Anglin dave.anglin <at> nrc-cnrc.gc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6602)
[make-prime-list.c.d (text/plain, attachment)]
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#12753
; Package
coreutils
.
(Mon, 29 Oct 2012 02:00:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 12753 <at> debbugs.gnu.org (full text, mbox):
On 10/28/2012 07:40 PM, John David Anglin wrote:
> make-prime-list crashes on hppa1.1-hp-hpux10.20. This probably
> will occur on any hppa-hpux system.
>
> Attached is a hack to work around the problem.
Is %jx not supported, or is the * not supported with %j?
I'm guessing the latter since you got a runtime issue
rather than a compile time one. We also use '*' in
other format strings, so I doubt that's an issue in itself.
Note there are only a couple of other uses of %j.
A newly introduced one in factor.c.
So does your system support %ju?
src/factor.c: printf ("%ju", t0);
Also this one introduced a year ago in an error path:
src/join.c: 0, _("%s:%ju: is not sorted: %.*s"),
I'm a little surprised (and encouraged) that there were
no reported compile issues for the %ju above, which
suggests we might be able to depend on that (well soon anyway).
Up until now we've been using the PRIuMAX etc. constants.
Un any case I might add a syntax check rule for the moment around
git grep "%[0*]*j[udx]"
to keep %j out of new code.
For this particular case can you test this more generic workaround.
thanks,
Pádraig.
diff --git a/src/make-prime-list.c b/src/make-prime-list.c
index e0d9b81..a4c0a3b 100644
--- a/src/make-prime-list.c
+++ b/src/make-prime-list.c
@@ -20,6 +20,7 @@ this program. If not, see http://www.gnu.org/licenses/. */
#include <config.h>
#include <stdint.h>
+#include <inttypes.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -77,17 +78,23 @@ output_primes (const struct prime *primes, unsigned nprimes)
exit (EXIT_FAILURE);
}
-#define SZ (int)(2*sizeof (uintmax_t))
+#if UINTMAX_MAX == UINT32_MAX
+# define SZ "8" /* 8 hex digits. */
+#elif UINTMAX_MAX == UINT64_MAX
+# define SZ "16" /* 16 hex digits. */
+#elif UINTMAX_MAX == UINT128_MAX
+# define SZ "32" /* 32 hex digits. */
+#endif
for (i = 0, p = 2; i < nprimes; i++)
{
unsigned int d8 = i + 8 < nprimes ? primes[i + 8].p - primes[i].p : 0xff;
if (255 < d8) /* this happens at 668221 */
abort ();
- printf ("P (%2u, %3u, 0x%0*jx%s, 0x%0*jx%s) /* %d */\n",
+ printf ("P (%2u, %3u, 0x%0"SZ PRIxMAX"%s, 0x%0"SZ PRIxMAX"%s) /* %d */\n",
primes[i].p - p, d8,
- SZ, primes[i].pinv, suffix,
- SZ, primes[i].lim, suffix, primes[i].p);
+ primes[i].pinv, suffix,
+ primes[i].lim, suffix, primes[i].p);
p = primes[i].p;
}
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#12753
; Package
coreutils
.
(Mon, 29 Oct 2012 12:26:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 12753 <at> debbugs.gnu.org (full text, mbox):
On 28-Oct-12, at 9:57 PM, Pádraig Brady wrote:
> Is %jx not supported, or is the * not supported with %j?
> I'm guessing the latter since you got a runtime issue
> rather than a compile time one. We also use '*' in
> other format strings, so I doubt that's an issue in itself.
I will test this evening. The printf manpage doesn't mention %j
or * in the HP-UX 10.20 and 11.11 pages. Sometimes things
are supported but not documented.
Dave
--
John David Anglin dave.anglin <at> bell.net
Reply sent
to
Pádraig Brady <P <at> draigBrady.com>
:
You have taken responsibility.
(Sun, 04 Nov 2012 00:59:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
John David Anglin <dave.anglin <at> nrc-cnrc.gc.ca>
:
bug acknowledged by developer.
(Sun, 04 Nov 2012 00:59:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 12753-done <at> debbugs.gnu.org (full text, mbox):
On 10/29/2012 12:22 PM, John David Anglin wrote:
> On 28-Oct-12, at 9:57 PM, Pádraig Brady wrote:
>
>> Is %jx not supported, or is the * not supported with %j?
>> I'm guessing the latter since you got a runtime issue
>> rather than a compile time one. We also use '*' in
>> other format strings, so I doubt that's an issue in itself.
>
>
> I will test this evening. The printf manpage doesn't mention %j
> or * in the HP-UX 10.20 and 11.11 pages. Sometimes things
> are supported but not documented.
I've now pushed the patch set from this thread,
so I'm marking this as done.
cheers,
Pádraig.
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#12753
; Package
coreutils
.
(Sun, 04 Nov 2012 01:24:01 GMT)
Full text and
rfc822 format available.
Message #19 received at 12753-done <at> debbugs.gnu.org (full text, mbox):
On 3-Nov-12, at 8:55 PM, Pádraig Brady wrote:
> On 10/29/2012 12:22 PM, John David Anglin wrote:
>> On 28-Oct-12, at 9:57 PM, Pádraig Brady wrote:
>>
>>> Is %jx not supported, or is the * not supported with %j?
>>> I'm guessing the latter since you got a runtime issue
>>> rather than a compile time one. We also use '*' in
>>> other format strings, so I doubt that's an issue in itself.
>>
>>
>> I will test this evening. The printf manpage doesn't mention %j
>> or * in the HP-UX 10.20 and 11.11 pages. Sometimes things
>> are supported but not documented.
>
> I've now pushed the patch set from this thread,
> so I'm marking this as done.
As far as I can tell, your patch to make-prime-list.c works. I'm
currently doing a build with a hack to try fix the threads issue.
The 'j' printf modifier is not supported on HP-UX at least through
to 11.11. GCC doesn't parse printf format strings to detect unsupported
features. The string "%ju" outputs "ju". As a result, the argument
processing messes up. This is what causes the runtime crash.
So, the other instances where %j is used need examination.
Don't know about '*'.
Thanks,
Dave
--
John David Anglin dave.anglin <at> bell.net
Information forwarded
to
bug-coreutils <at> gnu.org
:
bug#12753
; Package
coreutils
.
(Sun, 04 Nov 2012 01:45:01 GMT)
Full text and
rfc822 format available.
Message #22 received at 12753-done <at> debbugs.gnu.org (full text, mbox):
On 11/04/2012 01:19 AM, John David Anglin wrote:
> On 3-Nov-12, at 8:55 PM, Pádraig Brady wrote:
>
>> On 10/29/2012 12:22 PM, John David Anglin wrote:
>>> On 28-Oct-12, at 9:57 PM, Pádraig Brady wrote:
>>>
>>>> Is %jx not supported, or is the * not supported with %j?
>>>> I'm guessing the latter since you got a runtime issue
>>>> rather than a compile time one. We also use '*' in
>>>> other format strings, so I doubt that's an issue in itself.
>>>
>>>
>>> I will test this evening. The printf manpage doesn't mention %j
>>> or * in the HP-UX 10.20 and 11.11 pages. Sometimes things
>>> are supported but not documented.
>>
>> I've now pushed the patch set from this thread,
>> so I'm marking this as done.
>
>
> As far as I can tell, your patch to make-prime-list.c works. I'm
> currently doing a build with a hack to try fix the threads issue.
>
> The 'j' printf modifier is not supported on HP-UX at least through
> to 11.11. GCC doesn't parse printf format strings to detect unsupported
> features. The string "%ju" outputs "ju". As a result, the argument
> processing messes up. This is what causes the runtime crash.
>
> So, the other instances where %j is used need examination.
>
> Don't know about '*'.
Oh right, %j is only a runtime issue without -Wformat
Thanks for the info.
All %j should now be handled with:
http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=5e940180
http://git.sv.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=1411022c
thanks,
Pádraig.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 02 Dec 2012 12:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 11 years and 157 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.