Opened 14 years ago

Last modified 10 years ago

#2792 new Bugs

HP aCC rejects string_parse_tree <> in string_parse_tree.hpp

Reported by: Max Zinal <MaxZinal@…> Owned by: az_sw_dude
Milestone: To Be Determined Component: date_time
Version: Boost 1.38.0 Severity: Problem
Keywords: Cc:

Description

When trying to use date_time's format_date_parser<> I get errors on string_parse_tree<> template instantiation. The error message says "incomplete type is not allowed", the exact compiler version is HP C/aC++ B3910B A.06.20.

The core reason for the error is that string_parse_tree<> includes the definition of "ptree_coll" and several typedefs above it:

template<typename charT> struct string_parse_tree {

... typedef std::multimap<charT, string_parse_tree > ptree_coll; ... typedef typename ptree_coll::value_type value_type; typedef typename ptree_coll::iterator iterator; ... ptree_coll m_next_chars; ..

};

AFAIK this is not guaranteed to work by the current C++ standard, because string_parse_tree<> is, generally speaking, incomplete at the point of instantiation of ptree_coll.

I asked at comp.lang.c++.moderated, and these are the replies:

http://groups.google.ru/group/comp.lang.c++.moderated/browse_thread/thread/f04915083b8f0f93/a11c78689cffb71b

Attachments (3)

fix.2792.patch (3.7 KB ) - added by andrew.c.morrow@… 10 years ago.
Use shared_ptr to build tree, rather than by size self reference.
fix.2792.svn.patch (3.8 KB ) - added by andrew.c.morrow@… 10 years ago.
a better patch made via "svn diff"
fix.2792.new.patch (3.8 KB ) - added by andrew.c.morrow@… 10 years ago.
Re-uploading, something seems wrong with the previous upload

Download all attachments as: .zip

Change History (9)

comment:1 by Stuart A. Malone <samalone@…>, 10 years ago

I believe I am seeing the same problem with Boost 1.49 under the Xcode 4.4 developer preview 3 using the Apple LLVM compiler 4.0 and libc++ (LLVM C++ standard library with C++11 support. The string_parse_tree class is relying on undefined behavior when it attempts to use itself in the definition of ptree_coll.

I had a similar problem in my own code when I switched to this compiler/library combination, and solved it by using boost::shared_ptr to store a pointer to the sub-object rather than storing the complete object.

by andrew.c.morrow@…, 10 years ago

Attachment: fix.2792.patch added

Use shared_ptr to build tree, rather than by size self reference.

comment:2 by andrew.c.morrow@…, 10 years ago

I can confirm that this problem exists with Boost 1.50 under XCode 4.5 Developer Preview 2 when building boost with clang++. I've attached a very minimally tested patch against SVN 79489 that implements the shared_ptr fix mentioned by samalome above.

by andrew.c.morrow@…, 10 years ago

Attachment: fix.2792.svn.patch added

a better patch made via "svn diff"

comment:3 by andrew.c.morrow@…, 10 years ago

Milestone: Boost 1.39.0Boost 1.51.0

by andrew.c.morrow@…, 10 years ago

Attachment: fix.2792.new.patch added

Re-uploading, something seems wrong with the previous upload

comment:4 by andrew.c.morrow@…, 10 years ago

Ping? I'd really like to see this fixed for boost 1.51, but my updates in this ticket seem to have not generated much attention. This is a long standing problem in boost date_time and it breaks boost with recent versions of clang. I'm willing to help out with getting it fixed for the upcoming release. What can I do to help?

comment:5 by anonymous, 10 years ago

I'm also seeing this problem in clang 4.1, Boost 1.52. Patch appears to work.

comment:6 by anonymous, 10 years ago

Milestone: Boost 1.51.0To Be Determined
Note: See TracTickets for help on using tickets.