Wording inconsistency in the latest C++0x standard draft

Discussion in 'C++' started by ZMZ, Mar 3, 2011.

  1. ZMZ

    ZMZ Guest

    Hi, I found several errors in the draft, I hope I am not wrong. Please
    comment.

    I refer to the latest draft N3242 or N3225 (no too much difference
    with N3242).

    In the draft, an unnamed namespace becomes internal linkage (it was
    external linkage), the names used in unnamed namespace also becomes
    internal linkage (they were external linkage except for namespace
    name). As in 3.5/4,

    "An unnamed namespace or a namespace declared directly or indirectly
    within an unnamed namespace has internal linkage. All other namespaces
    have external linkage. A name having namespace scope that has not been
    given internal linkage above has the same linkage as the enclosing
    namespace......"

    But seems later usage of the term "external linkage" is not consistent
    with this new definition, specifically,

    1) 3.5/6 & 3.5/7

    "Otherwise, if no matching entity is found, the block scope entity
    receives external linkage."

    "When a block scope declaration of an entity with linkage is not found
    to refer to some other declaration, then that entity is a member of
    the innermost enclosing namespace." ( The first quote is wrong because
    that block scope entity might be a member of a namespace with internal
    linkage!)

    2) 9.3/3

    "[ Note: Member functions of a class in namespace scope have external
    linkage. " (how about class member functions in unnamed namespace?)

    3) 9.4.2/5

    "Static data members of a class in namespace scope have external
    linkage"

    4) 11.3/4

    "A function first declared in a friend declaration has external
    linkage" ( If I am not wrong, this friend function shall refer to a
    function within the inner most enclosing namespace, and it might have
    internal linkage.)

    5) 14/4

    "A non-member function template can have internal linkage; any other
    template name shall have external linkage."

    6) 14.3.2/4 I am not sure about this one, looking for clarification.
    I don't even understand why there is this rule.

    "Temporaries, unnamed lvalues, and named lvalues that do not have
    external linkage are not acceptable template-arguments when the
    corresponding template-parameter has reference type."

    7) 14.6.4.1/6

    "The instantiation context of an expression that depends on the
    template arguments is the set of declarations with external linkage
    declared prior to the point of instantiation of the template
    specialization in the same translation unit."

    I am not sure about this one but it looks suspicious to me. Names with
    no linkage and with internal linkage can be used as template argument
    now (If I am not wrong..), so why instantiation context must be
    declarations with external linkage?

    8) 14.6.4.2/1

    "If the function name is an unqualified-id and the call would be ill-
    formed or would find a better match had the lookup within the
    associated namespaces considered all the function declarations with
    external linkage introduced in those namespaces in all translation
    units, not just considering those declarations found in the template
    definition and template instantiation contexts, then the program has
    undefined behavior."

    My comment same as (7).

    Thanks for reading.
    ZMZ, Mar 3, 2011
    #1
    1. Advertising

  2. On 3 mar, 03:50, ZMZ <> wrote:
    > Hi, I found several errors in the draft, I hope I am not wrong. Please
    > comment.
    >
    > I refer to the latest draft N3242 or N3225 (no too much difference
    > with N3242).
    >
    > In the draft, an unnamed namespace becomes internal linkage (it was
    > external linkage), the names used in unnamed namespace also becomes
    > internal linkage (they were external linkage except for namespace
    > name). As in 3.5/4,
    >
    > "An unnamed namespace or a namespace declared directly or indirectly
    > within an unnamed namespace has internal linkage. All other namespaces
    > have external linkage.


    This part is the key:

    > A name having namespace scope that has not been
    > given internal linkage above has the same linkage as the enclosing
    > namespace......"


    My understanding if that in the rest of the document, a name that has
    not explicitely internal linkage has the linkage of enclosing
    namespace.

    > But seems later usage of the term "external linkage" is not consistent
    > with this new definition, specifically,


    As I read it, each time you see "external linkage" hereafter, in
    facts, it means "has linkage of the enclosing namespace". But if you
    see internal linkage, it doesn't take into account the enclosing
    namespace.

    [snip]

    IMHO, the wording have been kept for the general case (external
    linkage) and anonymous namespace is kept has an exception.

    --
    Michael
    Michael Doubez, Mar 3, 2011
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Frankie Montenegro
    Replies:
    3
    Views:
    511
    Frankie Montenegro
    Oct 14, 2005
  2. Paulo Jorge de O. C. de Matos

    Question on Wording

    Paulo Jorge de O. C. de Matos, Apr 26, 2008, in forum: C Programming
    Replies:
    8
    Views:
    326
    David Thompson
    May 5, 2008
  3. Jason R. Coombs
    Replies:
    0
    Views:
    216
    Jason R. Coombs
    Jun 13, 2008
  4. grocery_stocker
    Replies:
    4
    Views:
    245
    grocery_stocker
    May 2, 2009
  5. Alexander Terekhov
    Replies:
    21
    Views:
    905
    Keith H Duggar
    Jun 12, 2011
Loading...

Share This Page