3 ms·
I haven't been able to find anything in the C11 standard about the initialisation of bar being a constraint violation. In 6.7.3, the only constraints for type q
by lochsh 7y ago
I haven't been able to find anything in the C11 standard about the initialisation of bar being a constraint violation. In 6.7.3, the only constraints for type qualifiers listed are for _Atomic and restrict. Could you let me know where you got the information you talk about here from? I could be missing part of the standard.
- _kst_ 7y agoN1570 6.7.9p11 says that the constraints and conversions for simple assignment apply to scalar initializers. 6.5.16.1p1 says that, for pointers, "the type pointed to by the left has all the qualifiers of the type pointed to by the right". In this case, the right operand is a pointer to a const-qualified type and the left operand is a pointer to a non-const-qualified type. (Without this restriction, you could silently discard const qualification just by assigning or initializing a pointer, which would largely defeat the purpose of const.)