C++ Logo

std-discussion

Advanced search

Defect of the C Standard within the section "The typedef specifier"

From: Vladimir Grigoriev <vlad.moscow_at_[hidden]>
Date: Sat, 13 Nov 2021 11:44:02 +0300
Within the section 9.2.4 The typedef specifier of the C++ 20 Standard in the example2 of the paragraph 2 there is such an alias declaration
 
using cell = pair<void*, cell*>; // error
 
There is said nothing why this declaration is incorrect. So this example only confuses readers of the section. Actually such a declaration can be valid. Consider the following program
 
#include <utility>
 
using cell = int;
 
int main()
{
    using cell = std::pair<void *, cell *>;
    
    return 0;
}
 
According to the C++ 20 Standard (6.4.2 Point of declaration), p.3 ) «The point of declaration of an alias or alias template immediately follows the defining-type-id to which the alias refers»
 
So in the above program cell within the defining-type-id refers to the typedef id cell declared in the global namespace.
 
So just to write «error» for this line in the C++ Standard is not enough. Either this example should be excluded or appended with an explanation why there is an error.
 
With best regards
(Vlad from Moscow)
 
 
You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com

Received on 2021-11-13 02:44:12