Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #401328
| From | Tim Rentsch <tr.17687@z991.linuxsc.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Expression statements (was Re: Meaning of "expression") |
| Date | 2026-08-19 08:32 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <86ecfu15za.fsf@linuxsc.com> (permalink) |
| References | (16 earlier) <111q697$3cgp8$1@kst.eternal-september.org> <86qzlq7gkr.fsf@linuxsc.com> <111shoe$3vq40$3@kst.eternal-september.org> <86wlts5tbr.fsf@linuxsc.com> <115o0en$2rq0k$2@kst.eternal-september.org> |
Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
> 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:
>>>
>>>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>>
>>> [...]
>>>
>>>>> For example, this program:
>>>>>
>>>>> #include <stdio.h>
>>>>> int main(void) {
>>>>> const int result = printf("%ld\n", 0.3);
>>>>> printf("printf returned %d\n", result);
>>>>> }
>>>>>
>>>>> on my system prints:
>>>>>
>>>>> 140732048673560
>>>>> printf returned 16
>>>>>
>>>>> gcc and clang warn about the format string. tcc doesn't.
>>>>>
>>>>> The (first) printf call was apparently successful because printf
>>>>> has no way to know that the argument was of an incorrect type
>>>>> (types don't really exist at run time).
>>>>
>>>> printf() could know if an argument were of an incorrect type, if
>>>> an implementation chose to do so.
>>>
>>> Sure. I did write "on my system", where printf has no way to know
>>> that the argument was of an incorrect type.
>>
>> The "on my system" applies to what the program prints.
>>
>> The paragraph that says "printf has no way to know" is a general
>> statement, for any implementation of printf(). If you had meant it
>> to apply only to your system, you should have said something like
>> "because that printf had no way to know". Without any qualifying
>> adjective or other indicator the statement is generic, not
>> specific.
>
> [...] Certainly printf has no way defined by the language to know
> whether its arguments are of the correct types. An implementation
> could provide that information via some system-specific method,
> [...]
I'm glad to know we are in agreement.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Expression statements (was Re: Meaning of "expression") Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2026-06-28 02:49 +0200
Re: Expression statements (was Re: Meaning of "expression") Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-06-27 21:00 -0700
Re: Expression statements (was Re: Meaning of "expression") Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-06-28 09:52 -0700
Re: Expression statements (was Re: Meaning of "expression") Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-06-28 18:28 -0700
Re: Expression statements (was Re: Meaning of "expression") Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-08-14 13:40 -0700
Re: Expression statements (was Re: Meaning of "expression") Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-08-14 14:13 -0700
Re: Expression statements (was Re: Meaning of "expression") Tim Rentsch <tr.17687@z991.linuxsc.com> - 2026-08-19 08:32 -0700
Re: Expression statements (was Re: Meaning of "expression") Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2026-08-19 15:09 -0700
csiph-web