Topic: Defect Report: Use of typedef names in declarations


Author: iltchenko@yahoo.com (Andrei Iltchenko)
Date: 17 Dec 01 16:05:46 GMT
Raw View
 [Moderator's note: this defect report has been
 forwarded to the C++ committee. -moderator.]

Section: 3.5 - Program and linkage [basic.link]
Submitter: Andrei Iltchenko (iltchenko@yahoo.com)

Paragraph 8 of Section 3.5 [basic.link] contains the following
sentences: "A name with no linkage shall not be used to declare an
entity with linkage. If a declaration uses a typedef name, it is the
linkage of the type name to which the typedef refers that is
considered."

The problem with this wording is that it doesn't cover cases where the
type to which a typedef-name refers has no name. As a result it's not
clear whether, for example, the following program is well-formed:

#include <vector>

int  main()
{

   enum  {   sz = 6u   };
   typedef int  (* aptr_type)[sz];
   typedef struct  data  {
      int   i,  j;
   }  * elem_type;


   std::vector<aptr_type>   vec1;
   std::vector<elem_type>   vec2;

}


Suggested resolution:
My feeling is that the rules for whether or not a typedef-name used in
a declaration shall be treated as having or not having linkage ought
to be modelled after those for dependent types, which are explained in
14.6.2.1 [temp.dep.type].

Add the following text at the end of Paragraph 8 of Section 3.5
[basic.link] immediately before the example:

In case of the type referred to by a typedef declaration not having a
name, the newly declared typedef-name has linkage if and only if its
referred type comprises no names having no linkage. [Note: if the
referred type contains a typdef-name that does not denote an unnamed
class, the linkage of that name is established by the recursive
application of this rule for the purposes of using typedef names in
declarations.]


Regards,

Andrei Iltchenko.
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]