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


Groups > comp.lang.c > #176433

Re: Dymamic arrays: memory management and naming

From Keith Thompson <Keith.S.Thompson+u@gmail.com>
Newsgroups comp.lang.c
Subject Re: Dymamic arrays: memory management and naming
Date 2023-09-26 02:42 -0700
Organization None to speak of
Message-ID <87fs31tgnj.fsf@nosuchdomain.example.com> (permalink)
References (6 earlier) <20230924081911.947@kylheku.com> <20230925155845.139@kylheku.com> <86sf71itgt.fsf@linuxsc.com> <87msx9u09c.fsf@nosuchdomain.example.com> <86o7hpiggw.fsf@linuxsc.com>

Show all headers | View raw


Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>>> Kaz Kylheku <864-117-4973@kylheku.com> writes:
>>>> On 2023-09-24, Kaz Kylheku <864-117-4973@kylheku.com> wrote:
>>>>> h only makes sense if you're passing a signed argument and want
>>>>> it printed as unsigned.  Say we have 16 bit short and 32 bit int.
>>>>> Then "%u"/(short) -1 will print as 429496725, whereas
>>>>> "%hu"/(short) -1 will obtain the desired 65535.
>>>>
>>>> There is something I had neglected to mention:  the use of h for
>>>> portability
>>>>
>>>> If we have "%u" paired with an unsigned short, argument we have a
>>>> mismatch on a large number of platforms, where unsigned short
>>>> promotes to int.  The %u specifier wants unsigned int.
>>>
>>> A %u conversion specification is always okay for an unsigned
>>> short argument, regardless of whether the argument promotes to
>>> int or to unsigned int.  Reading an integer-typed variadic
>>> argument with the corresponding type of the other signedness
>>> is allowed when the argument value is representable in both
>>> types, which it always will be in this case even if unsigned
>>> short promotes to int.
>>
>> Agreed, but unfortunately the standard doesn't quite say that in
>> normative text -- until C23, as I discovered while writing this.
>> [...]
>
> My position is that this rule was intended since at least C99
> (and perhaps earlier) but was not expressed at unambiguously as
> one might like.

It was not expressed in normative text, ambiguously or otherwise.

> Also I believe there is support for this view if one consults
> various historical documents done by the ISO C committee.

You wouldn't have specific citations, would you?

In any case, the language is defined by the standard, not by
historical documents with wording that never made it into the
standard.  No implementer or programmer should have to consult
"historical documents" to determine what the standard requires.

> Also I think it is rather pointless to debate whether the C
> standard does or does not "say that in normative text" when
> the normative text that is there lends itself to different
> interpretations.  We all agree on what words are used;  what
> the words mean in this case is more a subjective reaction
> than an objective fact.  And is pretty much beside the point
> since what was intended and what was understood is the same
> for most of the people who are familiar with the C standard.

You consider it pointless.  I don't.  I find both the intent behind
the standard and what the standard says interesting.  In this case,
they were two different things, and I consider that to be a flaw
in the standard.  I'm glad the flaw is being corrected in C23.

-- 
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

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


Thread

Dymamic arrays: memory management and naming Anton Shepelev <anton.txt@gmail.moc> - 2023-09-09 13:23 +0300
  Re: Dymamic arrays: memory management and naming Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2023-09-09 03:56 -0700
  Re: Dymamic arrays: memory management and naming Kaz Kylheku <864-117-4973@kylheku.com> - 2023-09-09 15:06 +0000
  Re: Dymamic arrays: memory management and naming scott@slp53.sl.home (Scott Lurndal) - 2023-09-09 15:44 +0000
  Re: Dymamic arrays: memory management and naming Spiros Bousbouras <spibou@gmail.com> - 2023-09-10 17:57 +0000
    Re: Dymamic arrays: memory management and naming Anton Shepelev <anton.txt@gmail.moc> - 2023-09-10 23:49 +0300
      Re: Dymamic arrays: memory management and naming Kaz Kylheku <864-117-4973@kylheku.com> - 2023-09-10 21:25 +0000
  Re: Dymamic arrays: memory management and naming Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-09-12 16:07 -0700
    Re: Dymamic arrays: memory management and naming Anton Shepelev <anton.txt@gmail.moc> - 2023-09-17 00:44 +0300
  Re: Dymamic arrays: memory management and naming Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-09-17 16:51 -0700
    Re: Dymamic arrays: memory management and naming Anton Shepelev <anton.txt@gmail.moc> - 2023-09-19 01:10 +0300
      Re: Dymamic arrays: memory management and naming Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-09-19 07:58 -0700
      Re: Dymamic arrays: memory management and naming Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-09-19 10:33 -0700
        Re: Dymamic arrays: memory management and naming Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-09-19 15:08 -0700
          Re: Dymamic arrays: memory management and naming "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2023-09-19 15:35 -0700
          Re: Dymamic arrays: memory management and naming Kaz Kylheku <864-117-4973@kylheku.com> - 2023-09-19 22:49 +0000
            Re: Dymamic arrays: memory management and naming Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-09-19 22:30 -0700
              Re: Dymamic arrays: memory management and naming Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-09-20 02:46 -0700
                Re: Dymamic arrays: memory management and naming Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-09-20 07:06 -0700
              Re: Dymamic arrays: memory management and naming Kaz Kylheku <864-117-4973@kylheku.com> - 2023-09-20 21:03 +0000
                Re: Dymamic arrays: memory management and naming Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-09-25 14:08 -0700
                Re: Dymamic arrays: memory management and naming Kaz Kylheku <864-117-4973@kylheku.com> - 2023-09-25 21:27 +0000
          Re: Dymamic arrays: memory management and naming Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-09-19 22:17 -0700
        Re: Dymamic arrays: memory management and naming Anton Shepelev <anton.txt@gmail.moc> - 2023-09-24 00:39 +0300
          Re: Dymamic arrays: memory management and naming Blue-Maned_Hawk <bluemanedhawk@invalid.invalid> - 2023-09-23 21:48 +0000
          Re: Dymamic arrays: memory management and naming James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-09-24 00:15 -0400
          Re: Dymamic arrays: memory management and naming Spiros Bousbouras <spibou@gmail.com> - 2023-09-24 11:48 +0000
            Re: Dymamic arrays: memory management and naming Kaz Kylheku <864-117-4973@kylheku.com> - 2023-09-24 16:08 +0000
              Re: Dymamic arrays: memory management and naming Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-09-25 13:21 -0700
                Re: Dymamic arrays: memory management and naming Kaz Kylheku <864-117-4973@kylheku.com> - 2023-09-25 21:06 +0000
                Re: Dymamic arrays: memory management and naming Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-09-25 18:43 -0700
              Re: Dymamic arrays: memory management and naming Kaz Kylheku <864-117-4973@kylheku.com> - 2023-09-25 23:14 +0000
                Re: Dymamic arrays: memory management and naming Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-09-25 19:00 -0700
                Re: Dymamic arrays: memory management and naming Kaz Kylheku <864-117-4973@kylheku.com> - 2023-09-26 02:38 +0000
                Re: Dymamic arrays: memory management and naming Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-09-25 23:42 -0700
                Re: Dymamic arrays: memory management and naming Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-09-25 19:38 -0700
                Re: Dymamic arrays: memory management and naming Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-09-25 23:41 -0700
                Re: Dymamic arrays: memory management and naming Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2023-09-26 02:42 -0700
                Re: Dymamic arrays: memory management and naming Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-10-03 03:29 -0700
            Re: Dymamic arrays: memory management and naming Kaz Kylheku <864-117-4973@kylheku.com> - 2023-09-24 16:11 +0000
            Re: Dymamic arrays: memory management and naming James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-09-24 12:28 -0400
              Re: Dymamic arrays: memory management and naming Kaz Kylheku <864-117-4973@kylheku.com> - 2023-09-24 17:10 +0000
                Re: Dymamic arrays: memory management and naming James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-09-24 13:56 -0400
            Re: Dymamic arrays: memory management and naming Phil Carmody <pc+usenet@asdf.org> - 2023-09-30 13:50 +0300
              Re: Dymamic arrays: memory management and naming Spiros Bousbouras <spibou@gmail.com> - 2023-10-01 17:43 +0000
          Re: Dymamic arrays: memory management and naming Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-09-25 09:21 -0700
            Re: Dymamic arrays: memory management and naming Kaz Kylheku <864-117-4973@kylheku.com> - 2023-09-25 18:06 +0000
              Re: Dymamic arrays: memory management and naming Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-09-25 15:24 -0700
                Re: Dymamic arrays: memory management and naming Kaz Kylheku <864-117-4973@kylheku.com> - 2023-09-25 23:49 +0000
                Re: Dymamic arrays: memory management and naming Kaz Kylheku <864-117-4973@kylheku.com> - 2023-09-26 00:07 +0000

csiph-web