const qualifier for function type

Ian Lance Taylor iant@google.com
Sat Apr 2 17:23:00 GMT 2011


Nathan Ridge <zeratul976@hotmail.com> writes:

>> > Is the code ill-formed and gcc thus non-conforming?
>>
>> Those are two separate questions, 
>  
> Doesn't accepting invalid code make a compiler non-conforming?

There are a number of cases where the standard doesn't require a
conforming implementation to do anything in particular for an ill-formed
program.


>> but as far as I can tell, this code is
>> indeed ill-formed, and gcc should give an error for it. Please consider
>> filing an accepts-valid bug as described at http://gcc.gnu.org/bugs/ .
>
> I have filed http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48409.

Thanks.

>> > I ask because libstdc++ uses specializations like this for std::is_function in ,
>> > and as a result, clang refuses to compile anything that includes .
>>
>> I don't see that in the current . I see something
>> different in : the function is a template parameter. The
>> const qualifier is permitted if the function type is a
>> pointer-to-member. I think that may be possible in . In
>> that case, the const qualifier is not an error, and any use of it with
>> something that is not a pointer-to-member should be dropped due to
>> SFINAE. But I am not a C++ expert, and I could be wrong here.
>
> I was referring to the following:
>  
>   template<typename>
>     struct is_function
>     : public false_type { };
>   template<typename _Res, typename... _ArgTypes>
>     struct is_function<_Res(_ArgTypes...)>
>     : public true_type { };
>   template<typename _Res, typename... _ArgTypes>
>     struct is_function<_Res(_ArgTypes...) const>
>     : public true_type { };

Yes, me too, but that is very different from the example in your
original message.  Your example was about template specialization.  The
code quoted above is template definitions.

Ian



More information about the Gcc-help mailing list