1

I have written the following code(that uses typedef), which compiles with microsoft visual studio but not with gcc and clang.

using type = int(int)&; 
using type2 = type&;   //compiles with msvc but rejcted in gcc and clang 

Gcc says cannot declare reference to qualified reference type but msvc accepts it.

Is this another bug of msvc or the program is well-formed?

Val
  • 148
  • 8

1 Answers1

2

The given program is ill-formed because if a function-type has reference qualifier then we cannot create a reference to that function-type as per dcl.ref:

[Note 4: Forming a reference to function type is ill-formed if the function type has cv-qualifiers or a ref-qualifier; see [dcl.fct]. — end note]


And since type1=int(int)& is a function type with a reference-qualifier, we cannot create a reference to type1 as you're trying to do in type2.

Thus, msvc is wrong here.

Kal
  • 475
  • 1
  • 16