Skip to content

Possibility for function with cv-qualifier-seq be adjusted to function pointer #27059

Open
@llvmbot

Description

@llvmbot
Bugzilla Link26685
Versiontrunk
OSAll
AttachmentsA more detailed testcase
ReporterLLVM Bugzilla Contributor
CC@DougGregor,@hfinkel

Extended Description

Hello!

Simple code:

template <typename T> structtest { typedefvoid(* type)(T); }; typedefvoidfoo_t() const; typedef test<foo_t>::type func_t; 

We've got a function type with cv-qualifier-seq acquires the properties of a function pointer, although it's prohibited by Standard. This behavior occurs in the entire range of compilers.

Do I understand right that func_t (in this case) is invalid type, and it shouldn't be compiled?
So we can use it to bypass the restrictions and create a pointer to cv-qualified function:

template <typename F> structcreate_pointer { typedefvoidfunc_t(F); template <typename X> structextract { typedef X type; }; template <typename X> structextract<void(X)> { typedef X type; }; typedeftypename extract<func_t>::type type; }; intmain() { create_pointer<void() const>::type p = 0; }

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++clang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      close