All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Colomar <alx.manpages@gmail.com>
To: linux-man@vger.kernel.org, libc-alpha@sourceware.org
Cc: Walter Harms <wharms@bfs.de>
Subject: Re: [PATCH] register_printf_speficier.3, register_printf_modifier.3, register_printf_type.3: Add new manual page and links
Date: Mon, 19 Sep 2022 00:36:41 +0200	[thread overview]
Message-ID: <23ae1f95-d2aa-87f7-664e-ba3ffab16c43@gmail.com> (raw)
In-Reply-To: <20220918221640.19942-1-alx.manpages@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 1883 bytes --]

On 9/19/22 00:16, Alex Colomar wrote:
> And it seems I also need some help with my own example, since I
> discovered there's some sort of undefined behavior in it (just run
> it several times and see; some work, but some do show weird stuff
> for the cases where with modifiers that make the number wider than
> unsigned int).  If you find the undefined behavior, please show
> me.  I'll continue debugging, anyway.
> 


This is the UB I'm experiencing:

alx@dell7760:~/tmp$ ./a.out | head
....----....----....----....----
0000000000000000000000000000000000000000000000011111111111110100000000000000000000000001011110;
0000000000000000000000000000000000000000000000011111111111110100000000000000000000000001011110;
00000001011110;
00000001011110;
00000001011110;
0000000000000000000000000000000000000000000000011111111111110100000000000000000000000001011110;
0000000000000000000000000000000000000000000000011111111111110100000000000000000000000001011110;
....----....----....----....----
0b00000001011110;
alx@dell7760:~/tmp$ ./a.out | head
....----....----....----....----
00000001011110;
00000001011110;
00000001011110;
00000001011110;
00000001011110;
00000001011110;
00000001011110;
....----....----....----....----
0b00000001011110;


The first run is wrong, and the second one is correct.  The relevant 
printf(3) lines are:


            printf("....----....----....----....----\n");
            printf("%llb;\n", 0x5Ellu);
            printf("%lB;\n", 0x5Elu);
            printf("%b;\n", 0x5Eu);
            printf("%hB;\n", 0x5Eu);
            printf("%hhb;\n", 0x5Eu);
            printf("%jb;\n", (uintmax_t)0x5E);
            printf("%zb;\n", (size_t)0x5E);
            printf("....----....----....----....----\n");
            printf("%#b;\n", 0x5Eu);


Cheers,

Alex


-- 
<http://www.alejandro-colomar.es/>


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2022-09-18 22:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-18 22:16 [PATCH] register_printf_speficier.3, register_printf_modifier.3, register_printf_type.3: Add new manual page and links Alex Colomar
2022-09-18 22:36 ` Alex Colomar [this message]
2022-09-18 22:38   ` Alex Colomar
2022-09-18 23:09 ` [RFC v2] " Alex Colomar
2022-09-19  8:55   ` Alex Colomar
2022-09-18 23:18 ` [PATCH] " G. Branden Robinson
2022-09-18 23:25   ` Alex Colomar
2022-09-19 16:54 ` [RFC v3 0/4] Document <printf.h> Alex Colomar
2022-09-19 16:54 ` [RFC v3] printf.3head: Document functions for customizing printf(3)-like functions Alex Colomar
2022-09-19 16:54 ` [RFC v3 2/4] register_printf_specifier.3, register_printf_modifier.3, register_printf_type.3: Add links to printf.h(3head) Alex Colomar
2022-09-19 16:54 ` [RFC v3 3/4] printf_arginfo_size_function.3type, printf_function.3type, printf_info.3type, printf_va_arg_function.3type: " Alex Colomar
2022-09-19 16:54 ` [RFC v3 4/4] PA_CHAR.3const, PA_DOUBLE.3const, PA_FLAG_LONG.3const, PA_FLAG_LONG_DOUBLE.3const, PA_FLAG_LONG_LONG.3const, PA_FLAG_PTR.3const, PA_FLAG_SHORT.3const, PA_FLOAT.3const, PA_INT.3const, PA_LAST.3const, PA_POINTER.3const, PA_STRING.3const, PA_WCHAR.3const, PA_WSTRING.3const: " Alex Colomar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=23ae1f95-d2aa-87f7-664e-ba3ffab16c43@gmail.com \
    --to=alx.manpages@gmail.com \
    --cc=libc-alpha@sourceware.org \
    --cc=linux-man@vger.kernel.org \
    --cc=wharms@bfs.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.