Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

"Don't discount flying pigs before you have good air defense." -- jvh@clinet.FI


devel / comp.lang.c / Re: Why does C allow structs to have a tag?

SubjectAuthor
* Why does C allow structs to have a tag?James Harris
+* Re: Why does C allow structs to have a tag?David Brown
|`* Re: Why does C allow structs to have a tag?Thiago Adams
| `- Re: Why does C allow structs to have a tag?David Brown
+- Re: Why does C allow structs to have a tag?Öö Tiib
+* Re: Why does C allow structs to have a tag?Bart
|+* Re: Why does C allow structs to have a tag?Kaz Kylheku
||+- Re: Why does C allow structs to have a tag?Bart
||`* Re: Why does C allow structs to have a tag?Manfred
|| `* Re: Why does C allow structs to have a tag?David Brown
||  `* Re: Why does C allow structs to have a tag?Bart
||   +- Re: Why does C allow structs to have a tag?Richard Harnden
||   +* Re: Why does C allow structs to have a tag?Keith Thompson
||   |+* Re: Why does C allow structs to have a tag?Bart
||   ||+- Re: Why does C allow structs to have a tag?Keith Thompson
||   ||`* Re: Why does C allow structs to have a tag?James Harris
||   || `- Re: Why does C allow structs to have a tag?Bart
||   |`* Re: Why does C allow structs to have a tag?Manfred
||   | `* Re: Why does C allow structs to have a tag?Keith Thompson
||   |  `* Re: Why does C allow structs to have a tag?Bart
||   |   +* Re: Why does C allow structs to have a tag?David Brown
||   |   |`- Re: Why does C allow structs to have a tag?Bart
||   |   `* Re: Why does C allow structs to have a tag?Keith Thompson
||   |    `- Re: Why does C allow structs to have a tag?Malcolm McLean
||   `* Re: Why does C allow structs to have a tag?David Brown
||    `* Re: Why does C allow structs to have a tag?Bart
||     +* Re: Why does C allow structs to have a tag?David Brown
||     |`* Re: Why does C allow structs to have a tag?Bart
||     | `* Re: Why does C allow structs to have a tag?Malcolm McLean
||     |  `* Re: Why does C allow structs to have a tag?Bart
||     |   `* Re: Why does C allow structs to have a tag?Kaz Kylheku
||     |    `* Re: Why does C allow structs to have a tag?Bart
||     |     +- Re: Why does C allow structs to have a tag?James Harris
||     |     `* Re: Why does C allow structs to have a tag?Kaz Kylheku
||     |      `* Re: Why does C allow structs to have a tag?Bart
||     |       `* Re: Why does C allow structs to have a tag?Keith Thompson
||     |        `* Re: Why does C allow structs to have a tag?Bart
||     |         `- Re: Why does C allow structs to have a tag?Keith Thompson
||     `* Re: Why does C allow structs to have a tag?James Harris
||      `- Re: Why does C allow structs to have a tag?Bart
|`- Re: Why does C allow structs to have a tag?Keith Thompson
+* Re: Why does C allow structs to have a tag?Kaz Kylheku
|`* Re: Why does C allow structs to have a tag?Bart
| `- Re: Why does C allow structs to have a tag?James Harris
+- Re: Why does C allow structs to have a tag?James Kuyper
+* Re: Why does C allow structs to have a tag?Richard Damon
|`- Re: Why does C allow structs to have a tag?James Harris
+* Re: Why does C allow structs to have a tag?Joe Pfeiffer
|`* Re: Why does C allow structs to have a tag?Malcolm McLean
| +* Re: Why does C allow structs to have a tag?Guillaume
| |+* Re: Why does C allow structs to have a tag?Kaz Kylheku
| ||`* Re: Why does C allow structs to have a tag?Bart
| || `* Re: Why does C allow structs to have a tag?Kaz Kylheku
| ||  `* Re: Why does C allow structs to have a tag?Bart
| ||   `- Re: Why does C allow structs to have a tag?Keith Thompson
| |`* Re: Why does C allow structs to have a tag?James Kuyper
| | `* Re: Why does C allow structs to have a tag?Bart
| |  `* Re: Why does C allow structs to have a tag?Kaz Kylheku
| |   +* Re: Why does C allow structs to have a tag?Bart
| |   |`* Re: Why does C allow structs to have a tag?Kaz Kylheku
| |   | `* Re: Why does C allow structs to have a tag?Bart
| |   |  `* Re: Why does C allow structs to have a tag?David Brown
| |   |   `* Re: Why does C allow structs to have a tag?Bart
| |   |    +* Re: Why does C allow structs to have a tag?David Brown
| |   |    |`* Re: Why does C allow structs to have a tag?Bart
| |   |    | `* Re: Why does C allow structs to have a tag?David Brown
| |   |    |  +* Re: Why does C allow structs to have a tag?Manfred
| |   |    |  |`- Re: Why does C allow structs to have a tag?David Brown
| |   |    |  +- Re: Why does C allow structs to have a tag?Bart
| |   |    |  `* Re: Why does C allow structs to have a tag?Bart
| |   |    |   +- Re: Why does C allow structs to have a tag?David Brown
| |   |    |   `* Re: Why does C allow structs to have a tag?Keith Thompson
| |   |    |    +* Re: Why does C allow structs to have a tag?Guillaume
| |   |    |    |+* Re: Why does C allow structs to have a tag?Kaz Kylheku
| |   |    |    ||`- Re: Why does C allow structs to have a tag?Keith Thompson
| |   |    |    |+- Re: Why does C allow structs to have a tag?Keith Thompson
| |   |    |    |+- Re: Why does C allow structs to have a tag?Keith Thompson
| |   |    |    |`- Re: Why does C allow structs to have a tag?David Brown
| |   |    |    `* Re: Why does C allow structs to have a tag?Bart
| |   |    |     `* Re: Why does C allow structs to have a tag?Keith Thompson
| |   |    |      `* Re: Why does C allow structs to have a tag?Bart
| |   |    |       +* Re: Why does C allow structs to have a tag?Kaz Kylheku
| |   |    |       |`* Re: Why does C allow structs to have a tag?Ben Bacarisse
| |   |    |       | `* Re: Why does C allow structs to have a tag?Bart
| |   |    |       |  `* Re: Why does C allow structs to have a tag?Kaz Kylheku
| |   |    |       |   `* Re: Why does C allow structs to have a tag?Bart
| |   |    |       |    +* Re: Why does C allow structs to have a tag?Kaz Kylheku
| |   |    |       |    |`* Re: Why does C allow structs to have a tag?Bart
| |   |    |       |    | `- Re: Why does C allow structs to have a tag?Keith Thompson
| |   |    |       |    `- Re: Why does C allow structs to have a tag?Keith Thompson
| |   |    |       `- Re: Why does C allow structs to have a tag?David Brown
| |   |    `* Re: Why does C allow structs to have a tag?Kaz Kylheku
| |   |     `* Re: Why does C allow structs to have a tag?Bart
| |   |      `* Re: Why does C allow structs to have a tag?Kaz Kylheku
| |   |       `- Re: Why does C allow structs to have a tag?Bart
| |   `* Re: Why does C allow structs to have a tag?Bart
| |    +- Re: Why does C allow structs to have a tag?Keith Thompson
| |    `- Re: Why does C allow structs to have a tag?Kaz Kylheku
| +* Re: Why does C allow structs to have a tag?Joe Pfeiffer
| |`- Re: Why does C allow structs to have a tag?Kaz Kylheku
| `- Re: Why does C allow structs to have a tag?Richard Damon
+* Re: Why does C allow structs to have a tag?John Bode
+- Re: Why does C allow structs to have a tag?Siri Cruise
`* Re: Why does C allow structs to have a tag?Andrey Tarasevich

Pages:12345678910111213141516
Re: Why does C allow structs to have a tag?

<87h7fuilfh.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17945&group=comp.lang.c#17945

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Thu, 12 Aug 2021 11:10:10 -0700
Organization: None to speak of
Lines: 22
Message-ID: <87h7fuilfh.fsf@nosuchdomain.example.com>
References: <s9iea5$n5c$1@dont-email.me> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <WFWPI.1865$un2.1665@fx04.iad>
<FiCQI.401$uk4.259@fx20.iad> <poCQI.37363$EF2.25668@fx47.iad>
<VNCQI.5685$Ug5.514@fx24.iad> <seuu75$il3$1@dont-email.me>
<TEEQI.5686$Ug5.143@fx24.iad> <GCQQI.17254$lK.16624@fx41.iad>
<5d8700fd-6ba7-4c72-ae2f-1d4ea91fe823n@googlegroups.com>
<PHRQI.5464$xY.2133@fx05.iad> <sf0re4$v91$1@dont-email.me>
<sf1d0q$iiu$1@dont-email.me> <sf1had$5p9$1@dont-email.me>
<sf2m68$2q5$1@dont-email.me> <sf2vk1$t6o$1@dont-email.me>
<sf3b5u$eou$1@dont-email.me> <sf3ggk$m9i$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="9c12682f379b0ee3a947ffd4ce11d3dc";
logging-data="28512"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/3R0iEjxs6HSqqNmaR+4Cq"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:ln649Feg7KE4cNP3j7dYymZecZI=
sha1:szrcjnEnkhhn6s2gMGTwt/YX+zE=
 by: Keith Thompson - Thu, 12 Aug 2021 18:10 UTC

Bart <bc@freeuk.com> writes:
[...]
> Funny how one remark by Scott that was likely erroneous and misleading
> attracts virtually no comment. But someone TRIES to show that they are
> wrong, and you try to annihilate them.

It's even funnier that I replied to Scott's post, cited your results,
and pointed out that snprintf() is likely to have substantial overhead.
I suppose that doesn't count, since it doesn't fit into your narrative.

And it's hilarious that you have yet to acknowledge that you lied about
something I wrote here, falsely claiming that I had said that the end
user must obtain the components for a C implementation from different
sources and mix and match them.

I don't expect you to admit that you liked, but you could at least
acknowledge that I didn't say what you claim I said.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: Why does C allow structs to have a tag?

<sf3q8n$u9$1@z-news.wcss.wroc.pl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17946&group=comp.lang.c#17946

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!1.us.feeder.erje.net!feeder.erje.net!newsfeed.pionier.net.pl!pwr.wroc.pl!news.wcss.wroc.pl!not-for-mail
From: antis...@math.uni.wroc.pl
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Thu, 12 Aug 2021 18:45:44 +0000 (UTC)
Organization: Politechnika Wroclawska
Lines: 148
Message-ID: <sf3q8n$u9$1@z-news.wcss.wroc.pl>
References: <s9iea5$n5c$1@dont-email.me> <FiCQI.401$uk4.259@fx20.iad> <poCQI.37363$EF2.25668@fx47.iad> <VNCQI.5685$Ug5.514@fx24.iad> <seuu75$il3$1@dont-email.me> <TEEQI.5686$Ug5.143@fx24.iad> <GCQQI.17254$lK.16624@fx41.iad> <5d8700fd-6ba7-4c72-ae2f-1d4ea91fe823n@googlegroups.com> <PHRQI.5464$xY.2133@fx05.iad> <sf0re4$v91$1@dont-email.me> <sf1d0q$iiu$1@dont-email.me> <sf1had$5p9$1@dont-email.me> <sf2m68$2q5$1@dont-email.me> <sf2vk1$t6o$1@dont-email.me> <sf3jjj$kbl$1@z-news.wcss.wroc.pl>
NNTP-Posting-Host: hera.math.uni.wroc.pl
X-Trace: z-news.wcss.wroc.pl 1628793944 969 156.17.86.1 (12 Aug 2021 18:45:44 GMT)
X-Complaints-To: abuse@news.pwr.wroc.pl
NNTP-Posting-Date: Thu, 12 Aug 2021 18:45:44 +0000 (UTC)
Cancel-Lock: sha1:K4cCY8f6K0Z/qeHq97volvS+a8c=
User-Agent: tin/2.4.3-20181224 ("Glen Mhor") (UNIX) (Linux/4.19.0-10-amd64 (x86_64))
 by: antis...@math.uni.wroc.pl - Thu, 12 Aug 2021 18:45 UTC

antispam@math.uni.wroc.pl wrote:
> Bart <bc@freeuk.com> wrote:
> > On 12/08/2021 09:29, David Brown wrote:
> > > On 12/08/2021 00:00, Bart wrote:
> >
> > Try this version of getstr():
> >
> > char* getstr(void){
> > enum {N=10000};
> > static char* s=NULL;
> >
> > if (s) return s;
> >
> > s=malloc(N+1);
> > memset(s,'A',N);
> > s[N]=0;
> > return s;
> > }
> >
> > You may need to adjust the timing loop in the other module for fewer
> > iterations, and ensure the str[] array is big enough for 5 copies. (And
> > maybe comment out the bits that print the strings!)
>
> I used the following with 'strcpy' and 'strlen':
>
> #include <stdio.h>
> #include <string.h>
>
> char str[60*1000];
>
> extern char * get_str(void);
>
> int
> main(void) {
> char * s;
> char * ns;
> for (int i=0; i<100000; ++i) {
> ns = get_str();
> s = str;
> strcpy(s, ns);
> s += strlen(ns);
> strcpy(s, ns);
> s += strlen(ns);
> strcpy(s, ns);
> s += strlen(ns);
> strcpy(s, ns);
> s += strlen(ns);
> strcpy(s, ns);
> }
> puts(str);
> return 0;
> }
>
> but redirected output to '/dev/null'.
>
> time ./b5a > /dev/null
>
> real 0m0.400s
> user 0m0.400s
> sys 0m0.000s
>
> so 400ms for this version doing 100000
>
> With 'sprintf':
>
> #include <stdio.h>
> #include <string.h>
>
> char str[60*1000];
>
> extern char * get_str(void);
>
> int
> main(void) {
> char * s;
> char * ns;
> for (int i=0; i<100000; ++i) {
> ns = get_str();
> s = str;
> s += sprintf(s, "%s", ns);
> s += sprintf(s, "%s", ns);
> s += sprintf(s, "%s", ns);
> s += sprintf(s, "%s", ns);
> sprintf(s, "%s", ns);
> }
> puts(str);
> return 0;
> }
>
> time ./b5c > /dev/null
>
> real 0m0.473s
> user 0m0.468s
> sys 0m0.000s
>
> BTW: For my tests I used 'get_str', so I renamed yours to 'get_str'
> to fit.
>
> > You might be surprised at the results.
> >
> > (With N=1000000 here, and 100 iterations, gcc-O3 gave me figures of
> > 440/2320 msec - sprintf was still several times slower.)
>
> Well, there are various design points. On short strings on my
> machine I get similar time as you with 'sprintf' and 2.4s
> using 'strcat' + 'strlen'. But on longer strings seem to be
> much faster (as I wrote on my machine string handling is via
> SSE instructions).

A little correction, I messed up sources and binaries and
'strcpy' version was doing onlyu four copies in the loop.
I also tried version using 'memcpy' instead of 'strcpy',
the critical fragment being:

l = strlen(ns);
memcpy(s, ns, l+1);
s += l;

Now the results are:

time ./b5a > /dev/null

real 0m0.476s
user 0m0.468s
sys 0m0.000s

time ./b5c > /dev/null

real 0m0.475s
user 0m0.472s
sys 0m0.000s

time ./b5d > /dev/null

real 0m0.500s
user 0m0.488s
sys 0m0.000s

where 'b5a' uses 'strcpy', 'b5c' uses 'sprintf' and 'b5d' uses
'memcpy'. As you see 'strcpy' variant and 'sprintf' have
almost the same speed, while 'memcpy' is slightly slower.

FYI, for 'strcpy' + 'strlen' and 'sprintf' this means 6.57
characters per clock. 'memcpy' + 'strlen' is doing only
6.25 characters per clock.

--
Waldek Hebisch

Re: Why does C allow structs to have a tag?

<sf3r8r$25m$1@z-news.wcss.wroc.pl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17947&group=comp.lang.c#17947

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!news.uzoreto.com!news-out.netnews.com!news.alt.net!fdc2.netnews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer02.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!newsfeed.neostrada.pl!unt-exc-02.news.neostrada.pl!newsfeed.pionier.net.pl!pwr.wroc.pl!news.wcss.wroc.pl!not-for-mail
From: antis...@math.uni.wroc.pl
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Thu, 12 Aug 2021 19:02:51 +0000 (UTC)
Organization: Politechnika Wroclawska
Lines: 33
Message-ID: <sf3r8r$25m$1@z-news.wcss.wroc.pl>
References: <s9iea5$n5c$1@dont-email.me> <VNCQI.5685$Ug5.514@fx24.iad> <seuu75$il3$1@dont-email.me> <TEEQI.5686$Ug5.143@fx24.iad> <GCQQI.17254$lK.16624@fx41.iad> <5d8700fd-6ba7-4c72-ae2f-1d4ea91fe823n@googlegroups.com> <PHRQI.5464$xY.2133@fx05.iad> <sf0re4$v91$1@dont-email.me> <sf1d0q$iiu$1@dont-email.me> <sf1had$5p9$1@dont-email.me> <sf2m68$2q5$1@dont-email.me> <sf2vk1$t6o$1@dont-email.me> <sf3b5u$eou$1@dont-email.me> <sf3ggk$m9i$1@dont-email.me> <sf3mm1$4kk$1@dont-email.me>
NNTP-Posting-Host: hera.math.uni.wroc.pl
X-Trace: z-news.wcss.wroc.pl 1628794971 2230 156.17.86.1 (12 Aug 2021 19:02:51 GMT)
X-Complaints-To: abuse@news.pwr.wroc.pl
NNTP-Posting-Date: Thu, 12 Aug 2021 19:02:51 +0000 (UTC)
Cancel-Lock: sha1:8E1qcXGTL+k9F360Iv7EWQUE1l4=
User-Agent: tin/2.4.3-20181224 ("Glen Mhor") (UNIX) (Linux/4.19.0-10-amd64 (x86_64))
X-Received-Bytes: 2730
 by: antis...@math.uni.wroc.pl - Thu, 12 Aug 2021 19:02 UTC

David Brown <david.brown@hesbynett.no> wrote:
> On 12/08/2021 17:59, Bart wrote:
> > On 12/08/2021 15:28, David Brown wrote:
> >> On 12/08/2021 13:10, Bart wrote:
> >
> >>> (With N=1000000 here, and 100 iterations, gcc-O3 gave me figures of
> >>> 440/2320 msec - sprintf was still several times slower.)
> >>>
> >>
> >> I haven't claimed that sprintf is faster - I merely gave a possible
> >> explanation why it might be faster, for some situations.
> >
> > You said it's probably faster for short strings. It seems it can be
> > faster for much longer ones, but presumably not quoye as long as DFS's.
> >
>
> I said sprintf is going to be faster for /longer/ strings, because (in
> code sequences like your test code) it avoids the need to continually
> re-scan strings to find their length. That is, I think, quite obvious.

Well, if you do not see sources it is not obvious. 'strlen'
and 'strcpy' may have highly optimized implementation, while
'sprintf' could use some slow general code. On my machine
'sprintf' clearly is optimized, but takes essentially the
same time as 'strcpy' + 'strlen'. Interestingly, replacing
'strcpy' by 'memcpy' gave slower code.

If you consider that Bart is using what looks like quite recent
gcc toolchain on old version of Window, he may get quite strange
mix of library functions...

--
Waldek Hebisch

Re: Why does C allow structs to have a tag?

<sf3sdn$fjc$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17948&group=comp.lang.c#17948

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Thu, 12 Aug 2021 20:22:22 +0100
Organization: A noiseless patient Spider
Lines: 108
Message-ID: <sf3sdn$fjc$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <WFWPI.1865$un2.1665@fx04.iad>
<FiCQI.401$uk4.259@fx20.iad> <poCQI.37363$EF2.25668@fx47.iad>
<VNCQI.5685$Ug5.514@fx24.iad> <seuu75$il3$1@dont-email.me>
<TEEQI.5686$Ug5.143@fx24.iad> <GCQQI.17254$lK.16624@fx41.iad>
<5d8700fd-6ba7-4c72-ae2f-1d4ea91fe823n@googlegroups.com>
<PHRQI.5464$xY.2133@fx05.iad> <sf0re4$v91$1@dont-email.me>
<sf1d0q$iiu$1@dont-email.me> <sf1had$5p9$1@dont-email.me>
<sf2m68$2q5$1@dont-email.me> <sf2vk1$t6o$1@dont-email.me>
<sf3b5u$eou$1@dont-email.me> <sf3ggk$m9i$1@dont-email.me>
<sf3mm1$4kk$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 12 Aug 2021 19:22:31 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="99fe37e4e79e4f9d568828aa5779e349";
logging-data="15980"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18LCLm8Cc4SuUjfw1AIVRgmRqQCRt3UyQ0="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:B/XbeS3y5pqVsHSXZmnbM64h+T8=
In-Reply-To: <sf3mm1$4kk$1@dont-email.me>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210812-0, 12/8/2021), Outbound message
 by: Bart - Thu, 12 Aug 2021 19:22 UTC

On 12/08/2021 18:44, David Brown wrote:
> On 12/08/2021 17:59, Bart wrote:

>> That is just your opinion. Many of us do care about it, since
>> unoptimised code can give highly useful trade-offs (like 100 times
>> faster build speeds - ask any Rust developer whether they would like a
>> 100x faster build just once).
>
> I have no experience of Rust. But I can tell assure you that "gcc -O0"
> does not run 100 times faster than "gcc -O2", and is nowhere near as
> useful.

Unoptimised doesn't mean gcc -O0. For example:

C:\oldqx>tm gcc -O0 qq.c -oqqnop.exe
TM: 5.05

C:\oldqx>tm gcc -O2 qq.c -oqqopt.exe
TM: 16.91

C:\oldqx>tm tcc qq.c -oqqtcc.exe
TM: 0.17

gcc-O0 was ony 3.2 times as fast as gcc-O2. But tcc was pretty much 100
times as fast (and 123 times as fast as gcc-O3).

As for runtimes:

C:\oldqx>tm qqopt fib
fib(36) = 14930352
TM: 2.44

C:\oldqx>tm qqnop fib
fib(36) = 14930352
TM: 4.28

C:\oldqx>tm qqtcc fib
fib(36) = 14930352
TM: 5.24

Here, the trade-off for 100x faster compilation is that runtime is 2.14
times as long. But there are other non-optimising compilers:

C:\oldqx>tm mm qq
Compiling qq.m---------- to qq.exe
TM: 0.20

C:\oldqx>tm qq -fn fib
fib(36) = 14930352
TM: 4.11

About 77x faster compilatiOn, and 1.7 times longer runtime.

Or I can do this:

C:\oldqx>tm qq -asm fib
fib(36) = 14930352
TM: 0.74

So 77x faster compilation /and/ 3.3x FASTER runtime. Using my own ways
of optimising programs.

>> Any native code non-optimising compiler can still generate code that
>> will wipe the floor with any interpreted scripting language.
>>
>
> For most (for a very vague, hand-waving and unsubstantiated measurement
> of "most") code, run-time speed is not particularly important.

Well, the difference between code from gcc-O3 and tcc is generally just
over 2:1, and that's for computationally intensive code.

You're now saying that runtime speed isn't important after all. I don't
get you. Isn't that the main advantage of the optimisation flag on a
compiler?

You say here:

> No one (sane and knowledgable) cares about the speed of code generated
> by non-optimising compilers, or compilers with the optimisation turned
> off.

You seemed utterly dismissive about non-optimising compilers under any
circumstances. Now you seem to be acknowledging that perhaps their
somewhat poorer performance doesn't matter for a lot of code.

> I did not say that people don't run compilers without optimisations. I
> said that people who care about the speed of the results don't run
> compilers without optimisations.

Those people may care about having a lightweight, small-footprint and
nippy product; about not having to hang about to build any app; about
not needing to deal with innumerable, obscure compiler options; about
not having to mess with writing makefiles to ensure that incremental
compilation will work - just compile the lot; about creating an app
which doesn't care what compiler a third party may use, or which options
they choose.

They might also want a development system that is responsive even on
cheaper, low-end machines.

> If I want code to be fast, I enable optimisations. If I want it to be
> small, I enable optimisations.

If I use -Os on the above qq.c file, I get a 736KB executable. With my
MM compiler, it's 748KB; 1.6% bigger, but gcc took 67x longer, and it
runs a bit more slowly [than -O2].

Re: Why does C allow structs to have a tag?

<sf4366$uej$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17949&group=comp.lang.c#17949

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Thu, 12 Aug 2021 22:17:48 +0100
Organization: A noiseless patient Spider
Lines: 67
Message-ID: <sf4366$uej$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <WFWPI.1865$un2.1665@fx04.iad>
<FiCQI.401$uk4.259@fx20.iad> <poCQI.37363$EF2.25668@fx47.iad>
<VNCQI.5685$Ug5.514@fx24.iad> <seuu75$il3$1@dont-email.me>
<TEEQI.5686$Ug5.143@fx24.iad> <GCQQI.17254$lK.16624@fx41.iad>
<5d8700fd-6ba7-4c72-ae2f-1d4ea91fe823n@googlegroups.com>
<PHRQI.5464$xY.2133@fx05.iad> <sf0re4$v91$1@dont-email.me>
<sf1d0q$iiu$1@dont-email.me> <sf1had$5p9$1@dont-email.me>
<sf2m68$2q5$1@dont-email.me> <sf2vk1$t6o$1@dont-email.me>
<sf3jjj$kbl$1@z-news.wcss.wroc.pl>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 12 Aug 2021 21:17:58 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="99fe37e4e79e4f9d568828aa5779e349";
logging-data="31187"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19r7z+1zkxNTvMdyEY/KfL8n4XGKGZw4pQ="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:fTMS6rMSfXAQ2iI+zzDH+aoRglQ=
In-Reply-To: <sf3jjj$kbl$1@z-news.wcss.wroc.pl>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210812-0, 12/8/2021), Outbound message
 by: Bart - Thu, 12 Aug 2021 21:17 UTC

On 12/08/2021 17:52, antispam@math.uni.wroc.pl wrote:
> Bart <bc@freeuk.com> wrote:
>> On 12/08/2021 09:29, David Brown wrote:
>>> On 12/08/2021 00:00, Bart wrote:
>>
>> Try this version of getstr():
>>
>> char* getstr(void){
>> enum {N=10000};
>> static char* s=NULL;
>>
>> if (s) return s;
>>
>> s=malloc(N+1);
>> memset(s,'A',N);
>> s[N]=0;
>> return s;
>> }
>>
>> You may need to adjust the timing loop in the other module for fewer
>> iterations, and ensure the str[] array is big enough for 5 copies. (And
>> maybe comment out the bits that print the strings!)
>
> I used the following with 'strcpy' and 'strlen':
>
> #include <stdio.h>
> #include <string.h>
>
> char str[60*1000];
>
> extern char * get_str(void);
>
> int
> main(void) {
> char * s;
> char * ns;
> for (int i=0; i<100000; ++i) {
> ns = get_str();
> s = str;
> strcpy(s, ns);
> s += strlen(ns);
> strcpy(s, ns);
> s += strlen(ns);
> strcpy(s, ns);
> s += strlen(ns);
> strcpy(s, ns);
> s += strlen(ns);
> strcpy(s, ns);
> }
> puts(str);
> return 0;
> }

This combination is generally faster than strcat on my machine, even
without extracting the getstr() call into one variable. (That's intended
to represent some arbitrary string, that can change on each call.)

In some cases it was double the speed of strcat.

It was faster even when I put both into a single function 'strcpylen',
so needing one call to getstr. But trying to replace those two calls
inside strcpylen with an actual copying loop, to eliminate a separate
strlen, was much slower (between strcat and my sprintf).

In any case, I've seen no evidence that sprintf can be reliably faster
than strcat or strcpy etc. It's also more untidy to call.

Re: Why does C allow structs to have a tag?

<sf46lp$nif$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17950&group=comp.lang.c#17950

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: bc...@freeuk.com (Bart)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Thu, 12 Aug 2021 23:17:19 +0100
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <sf46lp$nif$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <WFWPI.1865$un2.1665@fx04.iad>
<FiCQI.401$uk4.259@fx20.iad> <poCQI.37363$EF2.25668@fx47.iad>
<VNCQI.5685$Ug5.514@fx24.iad> <seuu75$il3$1@dont-email.me>
<TEEQI.5686$Ug5.143@fx24.iad> <GCQQI.17254$lK.16624@fx41.iad>
<5d8700fd-6ba7-4c72-ae2f-1d4ea91fe823n@googlegroups.com>
<PHRQI.5464$xY.2133@fx05.iad> <sf0re4$v91$1@dont-email.me>
<sf1d0q$iiu$1@dont-email.me> <sf1had$5p9$1@dont-email.me>
<sf2m68$2q5$1@dont-email.me> <sf2vk1$t6o$1@dont-email.me>
<sf3b5u$eou$1@dont-email.me> <sf3ggk$m9i$1@dont-email.me>
<87h7fuilfh.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 12 Aug 2021 22:17:29 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="36dbdb3fbc2aa221a1f115d402718025";
logging-data="24143"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+e/axvm6huHuK1v6xEUCqm/52PsphKZyo="
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.11.0
Cancel-Lock: sha1:xM85cOQecXC6cR0yNlLzfs9yfEU=
In-Reply-To: <87h7fuilfh.fsf@nosuchdomain.example.com>
X-Antivirus-Status: Clean
Content-Language: en-GB
X-Antivirus: AVG (VPS 210812-10, 12/8/2021), Outbound message
 by: Bart - Thu, 12 Aug 2021 22:17 UTC

On 12/08/2021 19:10, Keith Thompson wrote:
> Bart <bc@freeuk.com> writes:
> [...]
>> Funny how one remark by Scott that was likely erroneous and misleading
>> attracts virtually no comment. But someone TRIES to show that they are
>> wrong, and you try to annihilate them.
>
> It's even funnier that I replied to Scott's post, cited your results,
> and pointed out that snprintf() is likely to have substantial overhead.
> I suppose that doesn't count, since it doesn't fit into your narrative.

'virtually'. Compare the total lines posted trashing my results.

> And it's hilarious that you have yet to acknowledge that you lied about
> something I wrote here, falsely claiming that I had said that the end
> user must obtain the components for a C implementation from different
> sources and mix and match them.

So then you admit that a C implementation usually comes as a ready-made
bundle WITH a compiler, headers, library (or arrangements for the
library) INCLUDING functions like printf, and any other tools necessary
to turn source into runnable code?

Because it seems to me that you've always claimed these parts as distinct.

Re: Why does C allow structs to have a tag?

<87czqii5kd.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17951&group=comp.lang.c#17951

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Thu, 12 Aug 2021 16:52:50 -0700
Organization: None to speak of
Lines: 62
Message-ID: <87czqii5kd.fsf@nosuchdomain.example.com>
References: <s9iea5$n5c$1@dont-email.me> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <WFWPI.1865$un2.1665@fx04.iad>
<FiCQI.401$uk4.259@fx20.iad> <poCQI.37363$EF2.25668@fx47.iad>
<VNCQI.5685$Ug5.514@fx24.iad> <seuu75$il3$1@dont-email.me>
<TEEQI.5686$Ug5.143@fx24.iad> <GCQQI.17254$lK.16624@fx41.iad>
<5d8700fd-6ba7-4c72-ae2f-1d4ea91fe823n@googlegroups.com>
<PHRQI.5464$xY.2133@fx05.iad> <sf0re4$v91$1@dont-email.me>
<sf1d0q$iiu$1@dont-email.me> <sf1had$5p9$1@dont-email.me>
<sf2m68$2q5$1@dont-email.me> <sf2vk1$t6o$1@dont-email.me>
<sf3b5u$eou$1@dont-email.me> <sf3ggk$m9i$1@dont-email.me>
<87h7fuilfh.fsf@nosuchdomain.example.com> <sf46lp$nif$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="2eb990256145d81ea1ee497015a0529a";
logging-data="24654"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+IUMdF5JKtjG/nPZOp7rOR"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:XRtGKlVXfTz7eUWD2vqfMHGG8v8=
sha1:6II/pIiUdQ/GLhH2+HHyUE24700=
 by: Keith Thompson - Thu, 12 Aug 2021 23:52 UTC

Bart <bc@freeuk.com> writes:
[SNIP]
>> And it's hilarious that you have yet to acknowledge that you lied about
>> something I wrote here, falsely claiming that I had said that the end
>> user must obtain the components for a C implementation from different
>> sources and mix and match them.
>
> So then you admit that a C implementation usually comes as a
> ready-made bundle WITH a compiler, headers, library (or arrangements
> for the library) INCLUDING functions like printf, and any other tools
> necessary to turn source into runnable code?

I do not "admit" it. The word "admit" implies that I've previously
stated otherwise. I have not. I certainly *acknowledge* it.

> Because it seems to me that you've always claimed these parts as distinct.

Yes, depending on what you mean by "distinct". The distinct components
are, in many cases, provided as a bundle. Sometimes the components are
all provided by the same provider. Sometimes they're provided by two or
more providers and somebody else creates the bundle, perhaps as part of
something larger. (For example, both gcc and glibc are pre-installed on
Ubuntu, at least in the configurations I've used.)

It is not typical for an end user to assemble the distinct components
into a working implementation.

Even if, for example, the compiler and the standard library are
tightly couple and provided in a single downloadable bundle, there
is still a clear internal distinction between them. There's no
particular requirement that they must be internally distinct, but
they (almost?) always are in practice, because it doesn't make
sense for them not to be.

Here's what you wrote:

| According to Keith, every C implementation consists of assorted
| components like this:
|
| * Possibly, a discrete preprocessor
| * Compiler
| * Standard headers
| * Assembler
| * Linker
| * Standard library
| * Extensions
|
| which everyone who ever installs an implementation is expected to obtain
| from different sources and mix and match to create a custom C system.

That is false; I did not say that. Typically "everyone who ever
installs an implementation" installs some bundle that already includes
the components that make up a C implementation.

Is it possible that you actually believed when you made that statement
that that was what I had said? I don't know *how* you could have
reached that conclusion.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: Why does C allow structs to have a tag?

<CHkRI.21412$6p.6928@fx36.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17952&group=comp.lang.c#17952

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!news.swapon.de!news.uzoreto.com!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!feeder5.feed.usenet.farm!feeder1.feed.usenet.farm!feed.usenet.farm!peer02.ams4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx36.iad.POSTED!not-for-mail
Subject: Re: Why does C allow structs to have a tag?
Newsgroups: comp.lang.c
References: <s9iea5$n5c$1@dont-email.me> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <WFWPI.1865$un2.1665@fx04.iad>
<FiCQI.401$uk4.259@fx20.iad> <poCQI.37363$EF2.25668@fx47.iad>
<VNCQI.5685$Ug5.514@fx24.iad> <seuu75$il3$1@dont-email.me>
<TEEQI.5686$Ug5.143@fx24.iad> <GCQQI.17254$lK.16624@fx41.iad>
<5d8700fd-6ba7-4c72-ae2f-1d4ea91fe823n@googlegroups.com>
<PHRQI.5464$xY.2133@fx05.iad> <sf0re4$v91$1@dont-email.me>
<sf1d0q$iiu$1@dont-email.me> <sf1had$5p9$1@dont-email.me>
<sf2m68$2q5$1@dont-email.me> <sf2vk1$t6o$1@dont-email.me>
<sf3b5u$eou$1@dont-email.me> <sf3ggk$m9i$1@dont-email.me>
<87h7fuilfh.fsf@nosuchdomain.example.com> <sf46lp$nif$1@dont-email.me>
<87czqii5kd.fsf@nosuchdomain.example.com>
From: Rich...@Damon-Family.org (Richard Damon)
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0)
Gecko/20100101 Thunderbird/78.13.0
MIME-Version: 1.0
In-Reply-To: <87czqii5kd.fsf@nosuchdomain.example.com>
Content-Type: text/plain; charset=utf-8
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Lines: 87
Message-ID: <CHkRI.21412$6p.6928@fx36.iad>
X-Complaints-To: abuse@easynews.com
Organization: Forte - www.forteinc.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Thu, 12 Aug 2021 22:22:25 -0400
X-Received-Bytes: 5519
 by: Richard Damon - Fri, 13 Aug 2021 02:22 UTC

On 8/12/21 7:52 PM, Keith Thompson wrote:
> Bart <bc@freeuk.com> writes:
> [SNIP]
>>> And it's hilarious that you have yet to acknowledge that you lied about
>>> something I wrote here, falsely claiming that I had said that the end
>>> user must obtain the components for a C implementation from different
>>> sources and mix and match them.
>>
>> So then you admit that a C implementation usually comes as a
>> ready-made bundle WITH a compiler, headers, library (or arrangements
>> for the library) INCLUDING functions like printf, and any other tools
>> necessary to turn source into runnable code?
>
> I do not "admit" it. The word "admit" implies that I've previously
> stated otherwise. I have not. I certainly *acknowledge* it.
>
>> Because it seems to me that you've always claimed these parts as distinct.
>
> Yes, depending on what you mean by "distinct". The distinct components
> are, in many cases, provided as a bundle. Sometimes the components are
> all provided by the same provider. Sometimes they're provided by two or
> more providers and somebody else creates the bundle, perhaps as part of
> something larger. (For example, both gcc and glibc are pre-installed on
> Ubuntu, at least in the configurations I've used.)
>
> It is not typical for an end user to assemble the distinct components
> into a working implementation.
>
> Even if, for example, the compiler and the standard library are
> tightly couple and provided in a single downloadable bundle, there
> is still a clear internal distinction between them. There's no
> particular requirement that they must be internally distinct, but
> they (almost?) always are in practice, because it doesn't make
> sense for them not to be.
>
> Here's what you wrote:
>
> | According to Keith, every C implementation consists of assorted
> | components like this:
> |
> | * Possibly, a discrete preprocessor
> | * Compiler
> | * Standard headers
> | * Assembler
> | * Linker
> | * Standard library
> | * Extensions
> |
> | which everyone who ever installs an implementation is expected to obtain
> | from different sources and mix and match to create a custom C system.
>
> That is false; I did not say that. Typically "everyone who ever
> installs an implementation" installs some bundle that already includes
> the components that make up a C implementation.
>
> Is it possible that you actually believed when you made that statement
> that that was what I had said? I don't know *how* you could have
> reached that conclusion.
>

Slight disagreement.

To the Standard, there is ONLY a complete implementation.

That implementation might be buildable out of building blocks, but as
far as the Standard is concerned, it is the responsibility of the entity
that puts it all together to make sure the results is 'Conforming'.

GCC, for example, it just a piece of an implementation, mostly the piece
called the 'compiler' (which I don't think is actually a defined term
for the Standard), and includes documentation for how to combine it with
the other pieces.

THere are library vendors who will provide other pieces of the
implementation, and documentation of how to combine it with other pieces
to make an implementation.

THen someone takes these pieces and creates the actual implementation.
They depend on the documentation from the various component vendors to
help them ensure that they make a 'Conforming' Implementation. If they
did the job right, it will be (or at least as close as practical
software will be to meeting some specification).

Sometimes the integrator intentionally makes the combination
non-conforming because that meets their needs better (perhaps adding a
non-conforming extension to the implementation). This is perfectly fine
too, 'Conformance' isn't the only criteria to judge an implementation by.

Re: Why does C allow structs to have a tag?

<878s16hxb6.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=17953&group=comp.lang.c#17953

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Thu, 12 Aug 2021 19:51:09 -0700
Organization: None to speak of
Lines: 96
Message-ID: <878s16hxb6.fsf@nosuchdomain.example.com>
References: <s9iea5$n5c$1@dont-email.me> <WFWPI.1865$un2.1665@fx04.iad>
<FiCQI.401$uk4.259@fx20.iad> <poCQI.37363$EF2.25668@fx47.iad>
<VNCQI.5685$Ug5.514@fx24.iad> <seuu75$il3$1@dont-email.me>
<TEEQI.5686$Ug5.143@fx24.iad> <GCQQI.17254$lK.16624@fx41.iad>
<5d8700fd-6ba7-4c72-ae2f-1d4ea91fe823n@googlegroups.com>
<PHRQI.5464$xY.2133@fx05.iad> <sf0re4$v91$1@dont-email.me>
<sf1d0q$iiu$1@dont-email.me> <sf1had$5p9$1@dont-email.me>
<sf2m68$2q5$1@dont-email.me> <sf2vk1$t6o$1@dont-email.me>
<sf3b5u$eou$1@dont-email.me> <sf3ggk$m9i$1@dont-email.me>
<87h7fuilfh.fsf@nosuchdomain.example.com> <sf46lp$nif$1@dont-email.me>
<87czqii5kd.fsf@nosuchdomain.example.com>
<CHkRI.21412$6p.6928@fx36.iad>
Mime-Version: 1.0
Content-Type: text/plain
Injection-Info: reader02.eternal-september.org; posting-host="2eb990256145d81ea1ee497015a0529a";
logging-data="11937"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19hBehPx/2CsGX4EE8uzagB"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:f0LQBVnxqG5PlmhHE1hum4Db3Js=
sha1:SfkxGU+ThHZWL2IInOlrQwu035Y=
 by: Keith Thompson - Fri, 13 Aug 2021 02:51 UTC

Richard Damon <Richard@Damon-Family.org> writes:
> On 8/12/21 7:52 PM, Keith Thompson wrote:
>> Bart <bc@freeuk.com> writes:
>> [SNIP]
>>>> And it's hilarious that you have yet to acknowledge that you lied about
>>>> something I wrote here, falsely claiming that I had said that the end
>>>> user must obtain the components for a C implementation from different
>>>> sources and mix and match them.
>>>
>>> So then you admit that a C implementation usually comes as a
>>> ready-made bundle WITH a compiler, headers, library (or arrangements
>>> for the library) INCLUDING functions like printf, and any other tools
>>> necessary to turn source into runnable code?
>>
>> I do not "admit" it. The word "admit" implies that I've previously
>> stated otherwise. I have not. I certainly *acknowledge* it.
>>
>>> Because it seems to me that you've always claimed these parts as distinct.
>>
>> Yes, depending on what you mean by "distinct". The distinct components
>> are, in many cases, provided as a bundle. Sometimes the components are
>> all provided by the same provider. Sometimes they're provided by two or
>> more providers and somebody else creates the bundle, perhaps as part of
>> something larger. (For example, both gcc and glibc are pre-installed on
>> Ubuntu, at least in the configurations I've used.)
>>
>> It is not typical for an end user to assemble the distinct components
>> into a working implementation.
>>
>> Even if, for example, the compiler and the standard library are
>> tightly couple and provided in a single downloadable bundle, there
>> is still a clear internal distinction between them. There's no
>> particular requirement that they must be internally distinct, but
>> they (almost?) always are in practice, because it doesn't make
>> sense for them not to be.
>>
>> Here's what you wrote:
>>
>> | According to Keith, every C implementation consists of assorted
>> | components like this:
>> |
>> | * Possibly, a discrete preprocessor
>> | * Compiler
>> | * Standard headers
>> | * Assembler
>> | * Linker
>> | * Standard library
>> | * Extensions
>> |
>> | which everyone who ever installs an implementation is expected to obtain
>> | from different sources and mix and match to create a custom C system.
>>
>> That is false; I did not say that. Typically "everyone who ever
>> installs an implementation" installs some bundle that already includes
>> the components that make up a C implementation.
>>
>> Is it possible that you actually believed when you made that statement
>> that that was what I had said? I don't know *how* you could have
>> reached that conclusion.
>>
>
> Slight disagreement.
>
> To the Standard, there is ONLY a complete implementation.
>
> That implementation might be buildable out of building blocks, but as
> far as the Standard is concerned, it is the responsibility of the entity
> that puts it all together to make sure the results is 'Conforming'.
>
> GCC, for example, it just a piece of an implementation, mostly the piece
> called the 'compiler' (which I don't think is actually a defined term
> for the Standard), and includes documentation for how to combine it with
> the other pieces.
>
> THere are library vendors who will provide other pieces of the
> implementation, and documentation of how to combine it with other pieces
> to make an implementation.
>
> THen someone takes these pieces and creates the actual implementation.
> They depend on the documentation from the various component vendors to
> help them ensure that they make a 'Conforming' Implementation. If they
> did the job right, it will be (or at least as close as practical
> software will be to meeting some specification).
>
> Sometimes the integrator intentionally makes the combination
> non-conforming because that meets their needs better (perhaps adding a
> non-conforming extension to the implementation). This is perfectly fine
> too, 'Conformance' isn't the only criteria to judge an implementation by.

Hmm. I agree with you, and I'm not sure how you disagree (slightly)
with me. The discussion was about typical implementations.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips
void Void(void) { Void(); } /* The recursive call of the void */

Re: Why does C allow structs to have a tag?

<8635qhx5v7.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18218&group=comp.lang.c#18218

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Mon, 06 Sep 2021 05:09:48 -0700
Organization: A noiseless patient Spider
Lines: 85
Message-ID: <8635qhx5v7.fsf@linuxsc.com>
References: <s9iea5$n5c$1@dont-email.me> <s9oidl$te9$1@dont-email.me> <867dijb22a.fsf@linuxsc.com> <sblh9g$muc$1@dont-email.me> <86a6mt8g69.fsf@linuxsc.com> <sdmi0u$55d$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="3555d3b4345d8bc729243ac3d8ab4b79";
logging-data="30354"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+v+2xradM0napZjqJXtKrXqJO6u4RREZo="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:Blv+h0rj8fbqvPxdgiQbVmzmTwU=
sha1:zuyIIUa6ymxgjzcZKZoAlPz1mxI=
 by: Tim Rentsch - Mon, 6 Sep 2021 12:09 UTC

John Bode <jfbode1029@gmail.com> writes:

> On 7/11/21 2:26 AM, Tim Rentsch wrote:
>
>> John Bode <jfbode1029@gmail.com> writes:
>>
>>> On 6/24/21 12:33 PM, Tim Rentsch wrote:
>>>
>>>> John Bode <jfbode1029@gmail.com> writes:
>>>>
>>>> [...]
>>>>
>>>>> To reiterate a point I make a lot - typedef on its own creates
>>>>> leaky abstractions. If I need to know that I have to use the
>>>>> `.` or `->` operator on something, I'd rather have it declared
>>>>> as `struct A foo;` or `struct B *ptr;` instead of a type name
>>>>> that doesn't convey struct-ness at all. Same reason I don't
>>>>> like it when people hide pointers behind typedefs - I once spent
>>>>> half a day chasing my tail because somebody created a typedef
>>>>> name for a pointer type and used that as a template parameter
>>>>> for a vector in C++, such that when I was using an iterator I
>>>>> needed to write
>>>>>
>>>>> (*it)->do_something();
>>>>>
>>>>> However, since the typedef name didn't indicate pointer-ness *at
>>>>> all*, I wound up writing
>>>>>
>>>>> it->do_something();
>>>>>
>>>>> and g++ vomited up hundreds of incomprehensible error messages
>>>>> that basically boiled down to "you need to use a * here, dummy".
>>>>
>>>> Sounds to me like the culprit is C++, not typedefs.
>>>
>>> g++ doesn't handle errors in template parameters very well and
>>> generates a *lot* of hard-to-follow error messages for relatively
>>> simple mistakes. And at the time I was still relatively
>>> inexperienced with C++, which didn't help.
>>>
>>> But the typedef name (or, more properly, the incomplete and leaky
>>> abstraction introduced by that typedef name) was the actual
>>> culprit. [...]
>>
>> I stand by my earlier claim that the culprit here is C++
>> rather than typedefs.
>
> I honestly don't know how to make it any clearer. I lost time due
> to using the wrong syntax. I was using the wrong syntax because the
> information I needed in order to use the right syntax was hidden
> from me. That's not a function of it being C++, that's a function
> of the abstraction not being complete.

You reported a case in a C++ program where confusion of pointer
versus non-pointer generated "hundreds of incomprehensible error
messages", causing you to lose time tracking down the problem.
Consider an analogous case in C:

it.do_something();

with 'it' having the pointer-concealing-typedef'ed type. In gcc
this expression produce a one-line error message:

what.c:7:15: error: 'it' is a pointer; did you mean to use '->'?

and in clang pretty much the same. If we consider a case with a
type that is a pointer to the pointer-concealing-typedef'ed type,
such as:

it->do_something();

where we should have used

(*it)->do_something();

again gcc gives a one-line error message:

what.c:11:15: error: '*it' is a pointer; did you mean to use '->'?

and clang again pretty much the same.

In all of these cases fixing the problem takes perhaps 15 to 30
seconds. By far the larger part of the problem is C++, not any
"hidden" pointerness, which is why I say that the culprit here is
C++ rather than typedefs.

Re: Why does C allow structs to have a tag?

<86y289vqt8.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18219&group=comp.lang.c#18219

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Mon, 06 Sep 2021 05:20:19 -0700
Organization: A noiseless patient Spider
Lines: 13
Message-ID: <86y289vqt8.fsf@linuxsc.com>
References: <s9iea5$n5c$1@dont-email.me> <s9oidl$te9$1@dont-email.me> <867dijb22a.fsf@linuxsc.com> <sblh9g$muc$1@dont-email.me> <86a6mt8g69.fsf@linuxsc.com> <sdmi0u$55d$1@dont-email.me> <20210727083246.384@kylheku.com> <se10pa$h58$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="3555d3b4345d8bc729243ac3d8ab4b79";
logging-data="30354"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+9mR061B8VfnHZgRy1fBNwbj81x+9+8KM="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:X/lF+jO1qNegV+u7C7mOkm2R2Ik=
sha1:EFiUhZhlzC0U2MRPUJlTi2yWUCM=
 by: Tim Rentsch - Mon, 6 Sep 2021 12:20 UTC

John Bode <jfbode1029@gmail.com> writes:

> Yeah, and what I'm saying is don't half-ass the abstraction - either
> make it fully abstract or don't bother. Don't hide the information
> I need to properly use the type behind a typedef. I would rather
> you leave the type "naked", even if it's more eye-stabby or a pain
> in the ass to type.

Note that what you're saying here is different from what you were
saying before. It isn't that putting pointerness inside typedefs
will per se cause problems, but only that you don't like them.
There's nothing wrong with having an opinion, but don't dress it
up as something more than what it is.

Re: Why does C allow structs to have a tag?

<86wnmyteyo.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18444&group=comp.lang.c#18444

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Thu, 30 Sep 2021 05:39:27 -0700
Organization: A noiseless patient Spider
Lines: 91
Message-ID: <86wnmyteyo.fsf@linuxsc.com>
References: <s9iea5$n5c$1@dont-email.me> <s9oidl$te9$1@dont-email.me> <867dijb22a.fsf@linuxsc.com> <sblh9g$muc$1@dont-email.me> <86a6mt8g69.fsf@linuxsc.com> <sdmi0u$55d$1@dont-email.me> <20210727083246.384@kylheku.com> <87h7gfiqu0.fsf@nosuchdomain.example.com> <sdpuui$1c0v$1@gioia.aioe.org> <Tw%LI.6384$XI4.2315@fx09.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="d4788905ada0446dfc3ae6b02ecc1355";
logging-data="12983"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19lUl3DcVE4xU9/vOB33lJ03xtRmbgjTdY="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:9TO+wly2o1EoYOjf8B4MIOV1kDI=
sha1:x4pDnrDfKvcxnwYCJ+1+XSTbwL8=
 by: Tim Rentsch - Thu, 30 Sep 2021 12:39 UTC

scott@slp53.sl.home (Scott Lurndal) writes:

> Guillaume <message@bottle.org> writes:
>
>> Le 27/07/2021 a` 19:55, Keith Thompson a @C3{A9}crit :
>>
>>> Kaz Kylheku <563-365-8930@kylheku.com> writes:
>>>
>>>> On 2021-07-26, John Bode <jfbode1029@gmail.com> wrote:
>>>>
>>>>> If you're going to hide a struct or union type behind a typedef
>>>>> name, don't make me hunt down the typedef to know how to access
>>>>> the members - provide an API to do that for me.
>>>>
>>>> I don't find that reasonable; it's pretty common to make typedef
>>>> names for structures just to have a shorthand for declaring them,
>>>> without intending to create a fully opaque type with abstracted
>>>> operations.
>>>>
>>>> typedef struct version {
>>>> int major;
>>>> int minor;
>>>> } version_t;
>>>>
>>>> The typedef is co-located with the struct declaration; your
>>>> ediutor should be able to jump to the definition of version_t
>>>> which is the above line.
>>>
>>> I disagree. I prefer to refer to the type as "struct version" and
>>> not bother with the typedef.
>>
>> Okay,then certainly it's a matter of taste, and that can't be
>> discussed.
>>
>> All I'm seeing though is that your argument could be used for just
>> any type really. Any typedef "hides" the type. It's made for
>> that. It's an abstraction. It's the whole point. Are you for
>> typeless languages?
>>
>> Or, what is it that you specifically have with structs that you
>> wouldn't mind with other types? Like, why does it bother you not
>> to directly see that a type is a struct, while the fact it's an
>> int, a double, or an array would matter to you? In any case, you
>> must know what a given type is for properly using it.
>
> Consider abstract types such as pid_t or off_t. [...]

Neither off_t nor pid_t is an abstract type. Both are signed
integer types with defined meanings for the values. In the case
of off_t, the value is how many bytes to go forward or backward.
In the case of pid_t, the value is the identifying number of the
process, with two distinguished values (0 and -1) that mean
something else. Knowing the identifying number of a process is
useful for comparing with things like 'ps' output. Also, even if
the identifying number of a process isn't especially useful by
itself, that the value is a signed integer can be useful for
other uses such as sorting or producing hash values. Such things
would not be available if these types were truly abstract types.

What these type names do provide is some amount of information
hiding, in particular how wide the underlying integer type is.
In most cases code doesn't need to know exactly how wide the
underlying type is. Following the principle (in programming)
that if it isn't really important to know something then it's
better not to know it, information about exactly which integer
types are used is hidden behind a typedef name.

> When you hide a struct behind a typedef, it's not opaque,
> as the field names are not generic (there was a time when any
> field name could be used with any pointer, but that's long in
> the past now).

Using a typedef name for a struct type similarly provides a
degree of information hiding. If there are 25 "clients" of a
struct type, and only 5 of them actually make use of the type's
"structness" (with . or ->), the other 20 can be written without
regard to whether the type is a struct or it isn't. The
principle of information hiding says doing that has value.
Conversely, not using a typedef name for said struct type forces
every client to be aware of the type being a struct type, whether
they need to know that or not. That's an unfortunate consequence
of a rule prohibiting the use of typedefs for struct types.

> I generally fall into Keith's camp on this in C, and in C++
> I never use typedef to hide a struct (the struct tag is,
> in a sense, a typedef in C++).

In many cases struct types are used as "mostly abstract" types,
with only a few use points needing to make use of member access.
In such cases it's nice to have the option of using a typedef so
that the type name reflects the dominant use case.

Re: Why does C allow structs to have a tag?

<86czootqz0.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18484&group=comp.lang.c#18484

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Fri, 01 Oct 2021 13:44:35 -0700
Organization: A noiseless patient Spider
Lines: 47
Message-ID: <86czootqz0.fsf@linuxsc.com>
References: <s9iea5$n5c$1@dont-email.me> <seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk> <WFWPI.1865$un2.1665@fx04.iad> <FiCQI.401$uk4.259@fx20.iad> <poCQI.37363$EF2.25668@fx47.iad> <VNCQI.5685$Ug5.514@fx24.iad> <seuu75$il3$1@dont-email.me> <TEEQI.5686$Ug5.143@fx24.iad> <sf021q$78n$1@z-news.wcss.wroc.pl> <2c0cb99f-2d5f-4149-8b03-d96ecc3d6543n@googlegroups.com> <kFQQI.17255$lK.6119@fx41.iad> <1f79b2e5-0e07-488f-a529-c00f7d6e046fn@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="1f711ea4a721fffeb2fc6a5c47f1cdc3";
logging-data="11894"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18VF9u7VJfytckXL+vm/eAcsIKxgO8kzJs="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:QYqPRk08kaClNwu54KTp+6Y7rtQ=
sha1:6qMbyrkM/eHFYs/fxMZ/BRhJ33g=
 by: Tim Rentsch - Fri, 1 Oct 2021 20:44 UTC

Michael S <already5chosen@yahoo.com> writes:

> On Wednesday, August 11, 2021 at 4:55:41 PM UTC+3, Scott Lurndal wrote:
>
>> Michael S <already...@yahoo.com> writes:
>>
>>> On Wednesday, August 11, 2021 at 11:34:16 AM UTC+3,
>>> anti...@math.uni.wroc.pl wrote:
>>> [...]
>>> strcat() should have been deprecated in 1989 with replacement that
>>> returns something potentially useful, e.g. pointer to
>>> termination character of result string or length of result string.
>>> Or return nothing, which still would be an improvement.
>>>
>>> But committees have their own logic.
>>
>> Having been a member of those committees for a decade, I'll point
>> out that deprecating or changing the semantics of strcat
>
> For me, deprecation does not mean *immediate* removal. For me, it
> mean that we threaten to remove a function in 15 years time and
> are actually removing it after 30 years. Or never.

The ISO C standard normally uses the term "obsolescent" to
indicate a language or library feature that may be removed at
some indeterminate point in the future. If ever, and not
necessarily - some language or library features have been
termed "obsolescent" in earlier versions of the C standard
but restored to non-obsolescent status in later versions.

The ISO C standard normally uses the term "deprecated" to
indicate a language or library feature that is expected to be
removed in some subsequent version of the C standard. There is a
good chance that removal happens soon (e.g., in the next release)
but there is no guarantee of that.

> But in the mean time conforming compilers issue annoying
> diagnostics.

The ISO C standard does not require diagnostics either for
obsolescent features or deprecated features. I think it's common
for implemenations to issue diagnostics for deprecated features
but that is completely up to the implementation. And of course
an implementation is free to issue diagnostics for anything it
wants to, as long as it accepts all strictly conforming programs
(and using obsolescent or deprecated features doesn't violate
that condition, IIANM).

Re: Why does C allow structs to have a tag?

<868rzctqqq.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18485&group=comp.lang.c#18485

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Fri, 01 Oct 2021 13:49:33 -0700
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <868rzctqqq.fsf@linuxsc.com>
References: <s9iea5$n5c$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk> <WFWPI.1865$un2.1665@fx04.iad> <FiCQI.401$uk4.259@fx20.iad> <poCQI.37363$EF2.25668@fx47.iad> <VNCQI.5685$Ug5.514@fx24.iad> <seuu75$il3$1@dont-email.me> <TEEQI.5686$Ug5.143@fx24.iad> <GCQQI.17254$lK.16624@fx41.iad> <5d8700fd-6ba7-4c72-ae2f-1d4ea91fe823n@googlegroups.com> <PHRQI.5464$xY.2133@fx05.iad> <sf0re4$v91$1@dont-email.me> <sf1d0q$iiu$1@dont-email.me> <sf1had$5p9$1@dont-email.me> <sf2m68$2q5$1@dont-email.me> <sf2vk1$t6o$1@dont-email.me> <sf3b5u$eou$1@dont-email.me> <sf3ggk$m9i$1@dont-email.me> <87h7fuilfh.fsf@nosuchdomain.example.com> <sf46lp$nif$1@dont-email.me> <87czqii5kd.fsf@nosuchdomain.example.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="1f711ea4a721fffeb2fc6a5c47f1cdc3";
logging-data="11894"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/L6vlVautGysBGUorcExVgwx4t2sLfey8="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:dNknHeh74IPUbELdF2++syVJ+9I=
sha1:1nIyOXd8zaXFscXJK3FicAUuIq0=
 by: Tim Rentsch - Fri, 1 Oct 2021 20:49 UTC

Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:

> Bart <bc@freeuk.com> writes:
> [SNIP]
>
>>> And it's hilarious that you have yet to acknowledge that you
>>> lied about something I wrote here, falsely claiming that I had
>>> said that the end user must obtain the components for a C
>>> implementation from different sources and mix and match them.
>>
>> So then you admit that a C implementation usually comes as a
>> ready-made bundle WITH a compiler, headers, library (or
>> arrangements for the library) INCLUDING functions like printf,
>> and any other tools necessary to turn source into runnable code?
>
> I do not "admit" it. The word "admit" implies that I've
> previously stated otherwise. [...]

In normal English usage the word "admit" neither requires nor
implies a previous statement to the contrary. For example, in
court a defendent may admit guilt without have made any previous
statement regarding guilt or innocence before pleading guilty.
Books and newspaper articles offer countless other examples.

Re: Why does C allow structs to have a tag?

<8635pktn9i.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18491&group=comp.lang.c#18491

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Fri, 01 Oct 2021 15:04:41 -0700
Organization: A noiseless patient Spider
Lines: 116
Message-ID: <8635pktn9i.fsf@linuxsc.com>
References: <s9iea5$n5c$1@dont-email.me> <see71a$gk4$1@dont-email.me> <seebtt$jrq$1@dont-email.me> <CjzOI.1030$Bg6.61@fx42.iad> <seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk> <WFWPI.1865$un2.1665@fx04.iad> <FiCQI.401$uk4.259@fx20.iad> <poCQI.37363$EF2.25668@fx47.iad> <VNCQI.5685$Ug5.514@fx24.iad> <seuu75$il3$1@dont-email.me> <TEEQI.5686$Ug5.143@fx24.iad> <sf021q$78n$1@z-news.wcss.wroc.pl> <875ywci8k0.fsf@bsb.me.uk> <63773d19-8176-43a0-9c6d-47f72b1e1c10n@googlegroups.com> <87tujwgldp.fsf@bsb.me.uk> <abc90066-026b-489d-9792-596e584c0af1n@googlegroups.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="394007ef4ff0447a8819fcdafe9c3245";
logging-data="22331"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/0iAhKj7qOhu9f5V9p3PQXIe9D1n06lfI="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:Wojrm41GlUlkqLlWHRYYl02g/uk=
sha1:haGCTXl1oWhiljHiIAtRJqhY9+g=
 by: Tim Rentsch - Fri, 1 Oct 2021 22:04 UTC

Michael S <already5chosen@yahoo.com> writes:

[...]

> The purpose of my_pritntf() is to prevent buffer overflows [...]
> rather than to always output something meaningful. [...]

Sounds useful and practical.

> [..some whitespace added in what follows..]
>
> #include <stdio.h>
> #include <limits.h>
> #include <stdarg.h>
>
> #include "my_snprintf.h"
>
> // my_snprintf - Write formatted output to sized buffer
> // my_snprintf is similar to snprintf() with following modifications
> //
> // 1. Argument n is signed. For n <= 0 the function does nothing
> // and returns 0
> //
> // 2. Return value is always a number of characters that have been
> // into s, not counting the terminating null character.
> //
> // The rest of description applies to case of positive n.
> // Unlike snprintf(), if an encoding error occurs, a 0 is returned
> // and the terminating null character is written to s[0].
> // Unlike snprintf(), if n had not been sufficiently large, a
> // value of n-1 is returned and the terminating null character is
> // written to s[n-1].
>
> int
> my_snprintf(char * s, ptrdiff_t n, const char * format, ...)
> {
> if (n <= 0)
> return 0;
> if (n > INT_MAX)
> n = INT_MAX;
>
> va_list args;
> va_start(args, format);
> int ret = vsnprintf(s, n, format, args);
> if (ret < 0)
> { // encoding error.
> // since our code uses no UNICODE, it should never happen,
> // but let's handle it nevertheless
> s[0] = 0; // may be, unnecessary
> return 0;
> }
>
> if (ret >= n) {
> s[n-1] = 0; // most likely unnecessary
> return n-1;
> }
>
> return ret;
> }

Some short comments:

One: signed types have issues. Rather than using a signed type
for the parameter 'n', use a large unsigned type such as unsigned
long long. Doing that still allows arguments having a signed
type to be checked for negative values, following the rules for
conversion of a signed value to an unsigned type.

Two: va_start() always requires a corresponding va_end().

Three: when supplying a *printf() function, it is customary to
supply also a corresponding *vprintf() function, which makes
writing the non-v form straightforward. It's two functions for
the price of one (plus only a little bit). Also it makes the
habit of using va_end() along with va_start() fall out with
essentially no effort.

To illustrate these points in C code, here is a revised writing
of my_snprintf(), along with my_vsnprintf();

// --- cut here ---

#include <limits.h>
#include <stdio.h>
#include <stdarg.h>

typedef unsigned long long ULL;

extern int my_vsnprintf( char *, ULL, const char *, va_list );

int
my_snprintf( char * s, ULL n, const char * format, ... ){
va_list args;
int r;

va_start( args, format );
r = my_vsnprintf( s, n, format, args );
va_end( args );

return r;
}

int
my_vsnprintf( char * s, ULL n0, const char * format, va_list args ){
if( n0 > -1ULL>>1 || n0 == 0 ) return 0;

size_t n = n0 > INT_MAX ? INT_MAX : n0;

int ret = vsnprintf( s, n, format, args );

return
ret < 0 ? s[0] = 0, 0 :
ret >= n ? s[n-1] = 0, n-1 :
ret;
}

Re: Why does C allow structs to have a tag?

<sj8rcj$c8h$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18498&group=comp.lang.c#18498

  copy link   Newsgroups: comp.lang.c
Path: rocksolid2!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: andreyta...@hotmail.com (Andrey Tarasevich)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Fri, 1 Oct 2021 22:40:32 -0700
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <sj8rcj$c8h$1@dont-email.me>
References: <s9iea5$n5c$1@dont-email.me> <seejf8$9ti$1@dont-email.me>
<WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me>
<CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me>
<87czqnlp2m.fsf@bsb.me.uk> <WFWPI.1865$un2.1665@fx04.iad>
<FiCQI.401$uk4.259@fx20.iad> <poCQI.37363$EF2.25668@fx47.iad>
<VNCQI.5685$Ug5.514@fx24.iad> <seuu75$il3$1@dont-email.me>
<TEEQI.5686$Ug5.143@fx24.iad> <sf021q$78n$1@z-news.wcss.wroc.pl>
<2c0cb99f-2d5f-4149-8b03-d96ecc3d6543n@googlegroups.com>
<kFQQI.17255$lK.6119@fx41.iad>
<1f79b2e5-0e07-488f-a529-c00f7d6e046fn@googlegroups.com>
<86czootqz0.fsf@linuxsc.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sat, 2 Oct 2021 05:40:35 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="29a9af493efe8e5255e256da5f14a025";
logging-data="12561"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18zx+LVkh8QrwtxKp9cfyby"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
Cancel-Lock: sha1:4jG52kkSgQuQTewXcBnHlyxtu+Y=
In-Reply-To: <86czootqz0.fsf@linuxsc.com>
Content-Language: en-US
 by: Andrey Tarasevich - Sat, 2 Oct 2021 05:40 UTC

On 10/1/2021 1:44 PM, Tim Rentsch wrote:
>
> The ISO C standard normally uses the term "obsolescent" to
> indicate a language or library feature that may be removed at
> ...
> The ISO C standard normally uses the term "deprecated" to
> indicate a language or library feature that is expected to be
> ...

Um...

The ISO C standard uses the term "obsolescent" to refer to features
marked for future removal. ISO C standard does designate the word
"deprecated" as a standard term. One can encounter the word "deprecated"
in the standard text, but it is never used to refer to language features.

"Deprecated" is used by C++ standard. "Deprecated" in C++ is an exact
synonym of "obsolescent" in C.

--
Best regards,
Andrey Tarasevich

Re: Why does C allow structs to have a tag?

<86tuhzstyl.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=18499&group=comp.lang.c#18499

  copy link   Newsgroups: comp.lang.c
Path: rocksolid2!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: Why does C allow structs to have a tag?
Date: Sat, 02 Oct 2021 01:37:38 -0700
Organization: A noiseless patient Spider
Lines: 54
Message-ID: <86tuhzstyl.fsf@linuxsc.com>
References: <s9iea5$n5c$1@dont-email.me> <seejf8$9ti$1@dont-email.me> <WowPI.4743$NQ1.1007@fx48.iad> <sembba$oul$1@dont-email.me> <CrQPI.669$bS5.239@fx21.iad> <seoqf4$pj7$1@dont-email.me> <87czqnlp2m.fsf@bsb.me.uk> <WFWPI.1865$un2.1665@fx04.iad> <FiCQI.401$uk4.259@fx20.iad> <poCQI.37363$EF2.25668@fx47.iad> <VNCQI.5685$Ug5.514@fx24.iad> <seuu75$il3$1@dont-email.me> <TEEQI.5686$Ug5.143@fx24.iad> <sf021q$78n$1@z-news.wcss.wroc.pl> <2c0cb99f-2d5f-4149-8b03-d96ecc3d6543n@googlegroups.com> <kFQQI.17255$lK.6119@fx41.iad> <1f79b2e5-0e07-488f-a529-c00f7d6e046fn@googlegroups.com> <86czootqz0.fsf@linuxsc.com> <sj8rcj$c8h$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="394007ef4ff0447a8819fcdafe9c3245";
logging-data="6215"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/C3N16HvdZSKI6mUNyVDV6VnCrNZXEg9E="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:/enHFKTQKcJWbXExihCUIX8rjDA=
sha1:BAV+ba3ayhJ+229tz5qrc62ZWCc=
 by: Tim Rentsch - Sat, 2 Oct 2021 08:37 UTC

Andrey Tarasevich <andreytarasevich@hotmail.com> writes:

> On 10/1/2021 1:44 PM, Tim Rentsch wrote:
>
>> The ISO C standard normally uses the term "obsolescent" to
>> indicate a language or library feature that may be removed at
>> ...
>> The ISO C standard normally uses the term "deprecated" to
>> indicate a language or library feature that is expected to be
>> ...
>
> Um...
>
> The ISO C standard uses the term "obsolescent" to refer to
> features marked for future removal.

No, it doesn't. ISO C standard, Introduction, paragraph 2:

Certain features are /obsolescent/, which means that they may
be considered for withdrawal in future revisions of this
International Standard.

Note the phrase "may be considered". (The slant characters around
the word obsolescent indicate italics, meaning a definition.) Such
features may be /considered/ for removal, but they are not /marked/
for removal.

> ISO C standard does designate the word "deprecated" as a standard
> term.

None of the several versions of the ISO C standard that I looked
at give a definition for "deprecate" or "deprecated". All use
the word, but none of them define it.

> One can encounter the word "deprecated" in the standard text, but
> it is never used to refer to language features.

Certainly it is is. For example N1256, which is C99 plus three
technical corrigenda, says this in 7.26.9 paragraph 2:

The gets function is obsolescent, and is deprecated.

> "Deprecated" is used by C++ standard. "Deprecated" in C++ is an
> exact synonym of "obsolescent" in C.

No, it isn't. A feature being obsolescent in C means only that
it "may be considered" at a later time, whereas a feature being
deprecated in C++ means that it "[has] been identified" as being
subject to removal in a later standard. The word obsolescent is
tentative, the word deprecated more definite. The two terms may
be related but they are not the same.

Pages:12345678910111213141516
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor