Re: C Strings not returning from a function
Keith Thompson wrote:
Rather feeble enforcement.
Or contains an expression that isn't well formed. In C++, an assignment
between incompatible types isn't well formed.
--
Ian Collins.
Keith Thompson wrote:
Ian Collins <ian-news@hotmail.co mwrites:
>
>
>
C does enforce the same rules. An assignment between incompatible
types is a constraint violation, requiring a diagnostic.
>
>
>>Keith Thompson wrote:
>>
>><OT>In C++, you can't assign or initialise with incompatible types, it's
>>an error.</OT>
>>
>>I can't see why C doesn't enforce the same rules, if you want to do an
>>incompatibl e assignment, you can force the issue with a cast.
>>
>>>Ian Collins <ian-news@hotmail.co mwrites:
>>>
>>>>A C++ compiler should refuse to compile the line you snipped;
>>>
>>>A C compiler should refuse to compile it.
>>>
>>>Actually, that's not quite true. Attempting to initialize a char*
>>>with a char** is a constraint violation. A conforming C compiler must
>>>issue a diagnostic. Once it's done so, it's not required either to
>>>accept or to reject the translation unit.
>>>
>>><OT>I *think* the rules are similar in C++, but I'm too lazy to search
>>>through the C++ standard for the corresponding wording. In any case,
>>>I *think* that Visual C++ can be used as a C compiler.</OT>
>>>
>>>
>>>>A C++ compiler should refuse to compile the line you snipped;
>>>
>>>A C compiler should refuse to compile it.
>>>
>>>Actually, that's not quite true. Attempting to initialize a char*
>>>with a char** is a constraint violation. A conforming C compiler must
>>>issue a diagnostic. Once it's done so, it's not required either to
>>>accept or to reject the translation unit.
>>>
>>><OT>I *think* the rules are similar in C++, but I'm too lazy to search
>>>through the C++ standard for the corresponding wording. In any case,
>>>I *think* that Visual C++ can be used as a C compiler.</OT>
>>>
>>an error.</OT>
>>
>>I can't see why C doesn't enforce the same rules, if you want to do an
>>incompatibl e assignment, you can force the issue with a cast.
>
C does enforce the same rules. An assignment between incompatible
types is a constraint violation, requiring a diagnostic.
>
A C compiler is never required to *reject* a translation unit unless
it contains a "#error" directive. (Many implementation-specific
extensions are implemented by giving meaning to code that would
otherwise violate a constraint.)
>
it contains a "#error" directive. (Many implementation-specific
extensions are implemented by giving meaning to code that would
otherwise violate a constraint.)
>
between incompatible types isn't well formed.
--
Ian Collins.
Comment