Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #91689

Re: Q: stdint format specifiers

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Q: stdint format specifiers
Date 2016-08-04 15:26 -0700
Organization None to speak of
Message-ID <lnr3a4yxvp.fsf@kst-u.example.com> (permalink)
References (1 earlier) <282c43f4-9e51-4c3c-9552-6703c60df230@googlegroups.com> <ln8twc1fpw.fsf@kst-u.example.com> <ad7f21a6-cd3b-450b-b625-a64fd3f4bdbd@googlegroups.com> <lnziosz0xx.fsf@kst-u.example.com> <ba812915-8a2f-4dcb-a86f-ccdff66d5df8@googlegroups.com>

Show all headers | View raw


supercat@casperkitty.com writes:
> On Thursday, August 4, 2016 at 4:19:59 PM UTC-5, Keith Thompson wrote:
>> Strictly speaking it's not just the *sizes* of the built-in types.  For
>> example, even if int and long both happen to be 32 bits, using "%d" with
>> a long argument or "%ld" with an int argument still has undefined
>> behavior (regardless of whether the declaration used "int", "int32_t",
>> or some other name).  The symptom of the UB is likely to be that it
>> "works", but it's still UB.
>
> Indeed, it would be hard for an implementation of printf to fetch the
> argument for %d or %ld without using a pointer of type "int*" or "long*"
> to read it, and it has become fashionable for compilers to assume that
> an int* cannot modify a "long", and a "long*" cannot modify an "int",
> even on platforms where both types have identical representations.

Good.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Q: stdint format specifiers Johann Klammer <klammerj@NOSPAM.a1.net> - 2016-08-04 18:11 +0200
  Re: Q: stdint format specifiers supercat@casperkitty.com - 2016-08-04 09:53 -0700
    Re: Q: stdint format specifiers Keith Thompson <kst-u@mib.org> - 2016-08-04 12:44 -0700
      Re: Q: stdint format specifiers Johann Klammer <klammerj@NOSPAM.a1.net> - 2016-08-04 22:57 +0200
      Re: Q: stdint format specifiers supercat@casperkitty.com - 2016-08-04 14:11 -0700
        Re: Q: stdint format specifiers Keith Thompson <kst-u@mib.org> - 2016-08-04 14:19 -0700
          Re: Q: stdint format specifiers supercat@casperkitty.com - 2016-08-04 15:08 -0700
            Re: Q: stdint format specifiers Keith Thompson <kst-u@mib.org> - 2016-08-04 15:26 -0700
          Re: Q: stdint format specifiers Malcolm McLean <malcolm.mclean5@btinternet.com> - 2016-08-04 23:19 -0700
            Re: Q: stdint format specifiers supercat@casperkitty.com - 2016-08-05 08:04 -0700
            Re: Q: stdint format specifiers Keith Thompson <kst-u@mib.org> - 2016-08-05 08:26 -0700

csiph-web