[Bug c++/48224] ERROR: compile in g++ version 4.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48224 --- Comment #7 from Evgenij evgenij.fokin at gmail dot com 2011-03-23 09:35:29 UTC --- Jonathan, I disagree with you. (In reply to comment #2) The C++ standard library says the effects are undefined if an incomplete type is used as a template argument when instantiating a template component (17.4.3.6p2) Yes, but instantiation made in cxx file where all types completed. In any case workaround have been found. Thank you, Andrew.
[Bug c++/48224] ERROR: compile in g++ version 4.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48224 --- Comment #8 from Jonathan Wakely redi at gcc dot gnu.org 2011-03-23 10:37:40 UTC --- (In reply to comment #7) Jonathan, I disagree with you. You're welcome to disagree, but you're wrong ;) In your original example the compiler tells you where the template is instantiated: compileError.hxx:11:62: instantiated from here At that point the type is incomplete. The example in comment 3 is also undefined, but compiles anyway. That doesn't make it correct. As I said, undefined means it might work, it might not, you can't rely on any specific behaviour. Compiling with -D_GLIBCXX_CONCEPT_CHECKS turns on C++03 concept checking, which tells you the problem: the concept checks fail for the code in comment 3 because the incomplete type does not meet the requirements of Assignable types (required by 23.1p3 [lib.containers.requirements] in C++03). Without concept checks it compiles OK because you don't do an assignment. In your original example you do an assignment on line 11, which is the point of instantiation that requires 'structure' to be complete.
[Bug c++/48224] ERROR: compile in g++ version 4.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48224 --- Comment #9 from Evgenij evgenij.fokin at gmail dot com 2011-03-23 11:09:25 UTC --- (In reply to comment #8) You're welcome to disagree, but you're wrong ;) The man who never made a mistake, never made anything :) Thank you for your quick response.
[Bug c++/48224] ERROR: compile in g++ version 4.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48224 Evgenij evgenij.fokin at gmail dot com changed: What|Removed |Added Status|RESOLVED|UNCONFIRMED Resolution|INVALID | --- Comment #3 from Evgenij evgenij.fokin at gmail dot com 2011-03-22 09:38:34 UTC --- Andrew, your code works fine. But this example can show another problem. Remove setter from code and change return type for getter. #include map struct structure; typedef std::mapint, structure mapOfStructure; class simpleClass { mapOfStructure m_mos; const mapOfStructure GetMos () const { return m_mos; } }; struct structure { int i; }; --- CUT --- Getter returns incomplete type but no compile error. Why the getter compiles without error and the setter compiles with error?
[Bug c++/48224] ERROR: compile in g++ version 4.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48224 Jonathan Wakely redi at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution||INVALID --- Comment #4 from Jonathan Wakely redi at gcc dot gnu.org 2011-03-22 10:18:49 UTC --- It's undefined behaviour, that means it might compile, it might not. You can't rely on any particular behaviour, so don't do it.
[Bug c++/48224] ERROR: compile in g++ version 4.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48224 --- Comment #5 from Evgenij evgenij.fokin at gmail dot com 2011-03-22 11:54:06 UTC --- Jonathan, what the document The C++ standard library do you mean? INTERNATIONAL STANDARD ISO/IEC 14882?
[Bug c++/48224] ERROR: compile in g++ version 4.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48224 --- Comment #6 from Jonathan Wakely redi at gcc dot gnu.org 2011-03-22 13:03:34 UTC --- yes
[Bug c++/48224] ERROR: compile in g++ version 4.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48224 Andrew Pinski pinskia at gcc dot gnu.org changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution||INVALID --- Comment #1 from Andrew Pinski pinskia at gcc dot gnu.org 2011-03-21 19:24:26 UTC --- I think this is correct as structure is incomplete when the instantiation of std::pairconst int, structure happens which is in SetMos. Try: #include map struct structure; typedef std::mapint, structure mapOfStructure; class simpleClass { mapOfStructure m_mos; const mapOfStructure GetMos () const { return m_mos; } inline void SetMos ( const mapOfStructure v ); }; struct structure { int i; }; inline void simpleClass::SetMos ( const mapOfStructure v ) { m_mos = v; } --- CUT --- Which is fixes the problem as pair needs both template arguments to be complete when SetMos is declared. Note I think it is needed for simpleClass is also declared really. So moving the declaration of structure before simpleClass is the correct fix really.
[Bug c++/48224] ERROR: compile in g++ version 4.5
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48224 --- Comment #2 from Jonathan Wakely redi at gcc dot gnu.org 2011-03-21 19:29:44 UTC --- The C++ standard library says the effects are undefined if an incomplete type is used as a template argument when instantiating a template component (17.4.3.6p2)