c++ - [bug] Compiler flags multiple identical member type definitions as error; should be warning
- Matthew (4/5) Dec 09 2005 `
- Walter Bright (2/2) Dec 09 2005 It's supposed to be an error.
- Matthew (6/8) Dec 09 2005 Well, I did leave the gate in my mind open for the possibility of being
- Walter Bright (4/10) Dec 10 2005 I don't remember, just that the allowance for multiple declarations of t...
- Matthew (9/21) Dec 10 2005 Which
- Walter Bright (11/34) Dec 10 2005 being
- Matthew (9/47) Dec 10 2005 type
- Walter Bright (16/21) Dec 11 2005 more
begin 666 dmmultiplemembertypedefbug.cpp` end
Dec 09 2005
It's supposed to be an error. BTW, the C++ standard does not require any warnings.
Dec 09 2005
"Walter Bright" <newshound digitalmars.com> wrote in message news:dndu5o$2t25$1 digitaldaemon.com...It's supposed to be an error.Well, I did leave the gate in my mind open for the possibility of being wrong (because I couldn't muster the effort to trawl the standard). Which clause relates?BTW, the C++ standard does not require any warnings.Indeed. ;-)
Dec 09 2005
"Matthew" <matthew hat.stlsoft.dot.org> wrote in message news:dne1ba$2vjk$2 digitaldaemon.com..."Walter Bright" <newshound digitalmars.com> wrote in message news:dndu5o$2t25$1 digitaldaemon.com...I don't remember, just that the allowance for multiple declarations of the same name is for global names.It's supposed to be an error.Well, I did leave the gate in my mind open for the possibility of being wrong (because I couldn't muster the effort to trawl the standard). Which clause relates?
Dec 10 2005
"Walter Bright" <newshound digitalmars.com> wrote in message news:dnfnep$2vjr$1 digitaldaemon.com..."Matthew" <matthew hat.stlsoft.dot.org> wrote in message news:dne1ba$2vjk$2 digitaldaemon.com...Which"Walter Bright" <newshound digitalmars.com> wrote in message news:dndu5o$2t25$1 digitaldaemon.com...It's supposed to be an error.Well, I did leave the gate in my mind open for the possibility of being wrong (because I couldn't muster the effort to trawl the standard).Sorry, buddy. I think you're wrong. Clause 7.1.3;2 states "In a given scope, a typedef specifier can be used to redefine the name of any type declared in that scope to refer to the type to which it already refers". There's no mention of this rule being applicable to global or namespace scope only.clause relates?I don't remember, just that the allowance for multiple declarations of the same name is for global names.
Dec 10 2005
"Matthew" <matthew hat.stlsoft.dot.org> wrote in message news:dnfsi9$2pn$1 digitaldaemon.com..."Walter Bright" <newshound digitalmars.com> wrote in message news:dnfnep$2vjr$1 digitaldaemon.com...being"Matthew" <matthew hat.stlsoft.dot.org> wrote in message news:dne1ba$2vjk$2 digitaldaemon.com..."Walter Bright" <newshound digitalmars.com> wrote in message news:dndu5o$2t25$1 digitaldaemon.com...It's supposed to be an error.Well, I did leave the gate in my mind open for the possibility oftheWhichwrong (because I couldn't muster the effort to trawl the standard).clause relates?I don't remember, just that the allowance for multiple declarations oftosame name is for global names.Sorry, buddy. I think you're wrong. Clause 7.1.3;2 states "In a given scope, a typedef specifier can be usedredefine the name of any type declared in that scope to refer to the typetowhich it already refers". There's no mention of this rule being applicable to global or namespace scope only.C++ 9.2-1 sez: "A member shall not be declared twice in the member-specification, except that a nested class or member class template can be declared and then later defined." 9.2-1 also specifically says that typedef's are considered members of a class. Check!
Dec 10 2005
"Walter Bright" <newshound digitalmars.com> wrote in message news:dngccp$gv6$1 digitaldaemon.com..."Matthew" <matthew hat.stlsoft.dot.org> wrote in message news:dnfsi9$2pn$1 digitaldaemon.com...type"Walter Bright" <newshound digitalmars.com> wrote in message news:dnfnep$2vjr$1 digitaldaemon.com...being"Matthew" <matthew hat.stlsoft.dot.org> wrote in message news:dne1ba$2vjk$2 digitaldaemon.com..."Walter Bright" <newshound digitalmars.com> wrote in message news:dndu5o$2t25$1 digitaldaemon.com...It's supposed to be an error.Well, I did leave the gate in my mind open for the possibility oftheWhichwrong (because I couldn't muster the effort to trawl the standard).clause relates?I don't remember, just that the allowance for multiple declarations oftosame name is for global names.Sorry, buddy. I think you're wrong. Clause 7.1.3;2 states "In a given scope, a typedef specifier can be usedredefine the name of any type declared in that scope to refer to thetoI'm happy to topple the king on this one. :-) I think it could still be argued either way, but I find 9.2;1 to be more specific than 7.1.3;2, and common sense should incline us to go for the more specific. Seems like writing a standard is probably even harder than reading one. Something to bear in mind ...which it already refers". There's no mention of this rule being applicable to global or namespace scope only.C++ 9.2-1 sez: "A member shall not be declared twice in the member-specification, except that a nested class or member class template can be declared and then later defined." 9.2-1 also specifically says that typedef's are considered members of a class. Check!
Dec 10 2005
"Matthew" <matthew hat.stlsoft.dot.org> wrote in message news:dngf7c$j3h$1 digitaldaemon.com...I think it could still be argued either way, but I find 9.2;1 to be more specific than 7.1.3;2, and common sense should incline us to go for themorespecific.I think it's nothing more than a contradiction in the standard that should be corrected with the next one. If one intends to write conforming code, one should take the most restrictive as the rule. A compiler implementer should implement the most expansive rule. I'm inclined to leave this one as it is in DMC++, however, because other C++ compilers disallow it, and because I can't think of a need to allow it. For the global case, however, it is a needed feature as a kludge to make up for the lack of true modules in C++. It enables things like: typedef unsigned short wchar_t; to appear in multiple .h files without a complex macro system that allows only one of them to be 'active.'Seems like writing a standard is probably even harder than reading one. Something to bear in mind ...Yup. It's as difficult to write it to be bug-free as writing the software itself.
Dec 11 2005