Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #379357
| From | Tim Rentsch <tr.17687@z991.linuxsc.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Call to a function |
| Date | 2023-10-29 09:01 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <86il6p1kql.fsf@linuxsc.com> (permalink) |
| References | (2 earlier) <87zg1et4wv.fsf@nosuchdomain.example.com> <86jzs3de3h.fsf@linuxsc.com> <87h6n7tkv4.fsf@nosuchdomain.example.com> <86ttqf2w6p.fsf@linuxsc.com> <uha5fs$2mvvu$1@i2pn2.org> |
Richard Damon <richard@damon-family.org> writes:
> On 10/24/23 8:54 PM, Tim Rentsch wrote:
>
>> Keith Thompson <Keith.S.Thompson+u@gmail.com> writes:
>>
>>> Tim Rentsch <tr.17687@z991.linuxsc.com> writes:
>>> [...]
>>>
>>>> The point isn't quite the same. The C standard explicitly says
>>>> integers may be converted to any pointer type. The C standard
>>>> does not say that a pointer to an object type may be converted
>>>> to a pointer to function type. Every implementation is within
>>>> its rights to reject any program whose static text includes[*] a
>>>> cast from a pointer to an object type to a pointer to function
>>>> type, regardless of whether the cast has any chance of being
>>>> executed.
>>>>
>>>> [*] meaning, still present as source of any preprocessor
>>>> conditionals have been processed, etc.
>>>
>>> I disagree. (I think we've discussed this before.)
>>>
>>> Concretely, I believe that this program violates no syntax error
>>> or constraint. It includes code whose behavior would be undefined
>>> if it were executed, but the `if (0)` prevents that.
>>>
>>> On what basis do you think a conforming implementation may reject
>>> it?
>>
>> First let me ask a question. Does the C standard allow an
>> implementation to reject any program that is not strictly
>> conforming?
>
> No, to reject a program it must violate some constraint.
>
> Not being 'strictly conforming' (a technical term in the Standard)
> is not a requirement for a program to be accepted.
In 4p6 the C standard says conforming implementations shall
accept any strictly conforming program. (There are some minor
differences between hosted implementations and freestanding
implementations but that's not important to the question.)
Does the C standard make any other statement about what programs
must be accepted? If so where are those statements? If not,
what is the basis for your statement that for an implementation
to reject a program the program must violate some constraint?
I'm assuming by the way that "reject" is being read as the
opposite of "accept", which is how I meant it: an implementation
rejects a program if and only if the implementation doesn't
accept the program. Come to think of it, "decline" might be a
better word choice for the opposite of "accept". Either way
though, the principle is that a program is either "accepted"
or "not accepted"; these is nothing in between.
(I should add that it is possible that a failure could occur
before an implementation could tell whether it would accept it or
not. I think it's logically consistent to count such cases as
accepted: if the program turns out to be strictly conforming,
the implementation has accepted it, and if the program turns out
to have an unskipped #error directive, the implementation has not
successfully translated it. So the requirements of the standard
are satisfied.)
> Now, there is the escape clause, that allows an implementation to
> fail to actually be able to run anything but the one specified
> program that meets all the minimum requirements, but that isn't
> grounds to 'reject' programs.
Accepting a program has nothing to do with actually running the
program; producing an executable is enough. Trying to produce
an executable but not succeeding because of one of the factors
mentioned in section 1 paragraph 2 still counts as accepting.
Implementation limits (as the term is used in the C standard)
fall in a different category. The standard requires an
implementation to accept a program if the program is strictly
conforming, but a program is not considered strictly conforming
if it exceeds a minimum implementation limit. Consider this
source file:
int one =
((((((((((((((((((((((((((((((((((((((((((((((((((
((((((((((((((((((((((((((((((((((((((((((((((((((
1
))))))))))))))))))))))))))))))))))))))))))))))))))
))))))))))))))))))))))))))))))))))))))))))))))))))
;
Can an implementation decline to translate this source file (and
so not accept it) and still be conforming? There are 100 nested
levels of parentheses.
Or consider this source file:
extern char big[ 2305843009213693952 ];
Can an implementation decline to translate this source file (and
so not accept it) and still be conforming? (The value of SIZE_MAX
may be assumed to be 2**64-1.)
For both of these questions, it may be assumed that the concerns
mentioned in 1p2 do not affect the answers.
Back to comp.lang.c | Previous | Next | Find similar | Unroll thread
Re: Call to a function Tim Rentsch <tr.17687@z991.linuxsc.com> - 2023-10-29 09:01 -0700
csiph-web