Re: const qualifier for function type

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Nathan Ridge <zeratul976@xxxxxxxxxxx> writes:

> GCC compiles the following code without error:
>
> template<typename>
> struct S;
>
> template <>
> struct S<void()>;
>
> template <>
> struct S<void() const>;
>
>
> However, both Comeau C++ and clang give the following error:
>
> error: type qualifier is not allowed on this function
> struct S<void() const>;
>
>
> Is the code ill-formed and gcc thus non-conforming?

Those are two separate questions, 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 ask because libstdc++ uses specializations like this for std::is_function in <type_traits>, 
> and as a result, clang refuses to compile anything that includes <type_traits>.

I don't see that in the current <type_traits>.  I see something
different in <type_traits>: 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 <type_traits>.  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.

Ian


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux