Bug 620095

Summary: Code does not compile with gcc 4.5
Product: [Fedora] Fedora Reporter: Braden McDaniel <braden>
Component: gccAssignee: Jakub Jelinek <jakub>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 14CC: dodji, jakub, nobody+dseketel
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: gcc-4.5.1-3.fc14 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-09-11 03:36:02 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 631089    
Attachments:
Description Flags
koji build log from rawhide
none
Preprocessed source none

Description Braden McDaniel 2010-07-31 21:03:01 UTC
Created attachment 435800 [details]
koji build log from rawhide

Description of problem:
openvrml includes some code using boost::spirit that looks like this:

    template <typename Actions = null_x3d_vrml_parse_actions,
              typename ErrorHandler = x3d_vrml_parse_error_handler>
    struct x3d_vrml_grammar :
        boost::spirit::classic::grammar<x3d_vrml_grammar<Actions, ErrorHandler> > {

        template <typename ScannerT>
        struct definition :
            vrml97_grammar<Actions, ErrorHandler>::
            template definition<ScannerT> {
            ...
            static const boost::spirit::classic::functor_parser<
                typename base_t::template mftype_parser<
                    boost::spirit::classic::functor_parser<openvrml::bool_parser> > >
                mfbool_p;
            ...
        };
        ...
    };

    template <typename Actions, typename ErrorHandler>
    template <typename ScannerT>
    const boost::spirit::classic::functor_parser<
        typename vrml97_grammar<Actions, ErrorHandler>::template definition<ScannerT>::
        template mftype_parser<boost::spirit::classic::functor_parser<openvrml::bool_parser> > >
    x3d_vrml_grammar<Actions, ErrorHandler>::definition<ScannerT>::mfbool_p =
        typename vrml97_grammar<Actions, ErrorHandler>::template definition<ScannerT>::
        template mftype_parser<
            boost::spirit::classic::functor_parser<openvrml::bool_parser>
        >(bool_p);

This is eliciting an error message from g++ 4.5:

In file included from libopenvrml/openvrml/basetypes.cpp:23:0:
libopenvrml/openvrml/x3d_vrml_grammar.h:726:68: error: conflicting declaration 'const boost::spirit::classic::functor_parser<typename openvrml::vrml97_grammar<Actions, ErrorHandler>::definition<ScannerT>::mftype_parser<boost::spirit::classic::functor_parser<openvrml::bool_parser> > > openvrml::x3d_vrml_grammar<Actions, ErrorHandler>::definition<ScannerT>::mfbool_p'
libopenvrml/openvrml/x3d_vrml_grammar.h:651:17: error: 'openvrml::x3d_vrml_grammar<Actions, ErrorHandler>::definition<ScannerT>::mfbool_p' has a previous declaration as 'const boost::spirit::classic::functor_parser<typename openvrml::vrml97_grammar<Actions, ErrorHandler>::definition<ScannerT>::mftype_parser<boost::spirit::classic::functor_parser<openvrml::bool_parser> > > openvrml::x3d_vrml_grammar<Actions, ErrorHandler>::definition<ScannerT>::mfbool_p'
libopenvrml/openvrml/x3d_vrml_grammar.h:726:68: error: declaration of 'const boost::spirit::classic::functor_parser<typename openvrml::vrml97_grammar<Actions, ErrorHandler>::definition<ScannerT>::mftype_parser<boost::spirit::classic::functor_parser<openvrml::bool_parser> > > openvrml::x3d_vrml_grammar<Actions, ErrorHandler>::definition<ScannerT>::mfbool_p' outside of class is not definition

This code was accepted by gcc 4.4. If there is a legitimate syntax issue here, I'm not sure what it is.

Version-Release number of selected component (if applicable):
4.5.0-3.fc14

Comment 1 Jakub Jelinek 2010-08-11 07:04:18 UTC
Please provide preprocessed source and the g++ options used to compile it.

Comment 2 Braden McDaniel 2010-08-11 15:39:04 UTC
If there's a way to obtain that from koji, I don't know what it is.

I don't have other access to a machine with gcc 4.5 at the moment, so it's rather difficult for me to get the preprocessed source. This can be reproduced by building the openvrml package on the F14 or development branches.

Comment 3 Jakub Jelinek 2010-08-12 16:56:41 UTC
Just build it with mock...

Comment 4 Braden McDaniel 2010-09-06 04:45:51 UTC
Created attachment 443222 [details]
Preprocessed source

The command line being used to compile:

g++ -DHAVE_CONFIG_H -I. -I.. -I../src/libopenvrml -I../src/libopenvrml -I../src/local/libopenvrml-dl -DOPENVRML_LIBDIR_=\"/usr/lib64\" -DOPENVRML_PKGDATADIR_=\"/usr/share/openvrml\" -DOPENVRML_PKGLIBDIR_=\"/usr/lib64/openvrml\" -DBOOST_MPL_CFG_NO_PREPROCESSED_HEADERS -DBOOST_MPL_LIMIT_VECTOR_SIZE=30 -I/usr/lib/jvm/java/include -I/usr/lib/jvm/java/include/linux -DNDEBUG -I/usr/include/freetype2 -pthread -I/usr/include/libxml2 -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -fvisibility=hidden -fvisibility-inlines-hidden -Wno-missing-braces -Wno-strict-aliasing -Wno-unused-variable -c libopenvrml/openvrml/basetypes.cpp  -fPIC -DPIC -o libopenvrml/openvrml/.libs/libopenvrml_libopenvrml_la-basetypes.o

Comment 5 Jakub Jelinek 2010-09-06 10:12:37 UTC
Dodji, this error starts appearing with r156316 (i.e. your PR42713 + PR42820 patch).  Can you please look at it?  -O0 is enough to reproduce (with # lines stripped -O0 -std=gnu++0x).

Comment 6 Jakub Jelinek 2010-09-06 11:02:21 UTC
Hopefully correctly simplified testcase, at least I get the same error on it with r156316 and no error with r156312.

template <typename S, typename T>
struct C
{
  template <typename U>
  struct B
  {
    template <typename W>
    struct E
    {
      explicit E(const W &x) : w(x) {}
      const W &w;
    };
  };
};
struct F;
template <typename X>
struct D
{
  D() {}
};
const D<F> g;
template <typename S, typename T>
struct A
{
  template <typename U>
  struct B : C<S, T>::template B<U>
  {
    typedef typename C<S, T>::template B<U> V;
    static const D<typename V::template E<D<F> > > a;
  };
};
template <typename S, typename T>
template <typename U>
const D<typename C<S, T>::template B<U>::template E<D<F> > >
A<S, T>::B<U>::a = typename C<S, T>::template B<U>::template E<D<F> >(g);

Comment 7 Dodji Seketeli 2010-09-07 07:14:55 UTC
This should be fixed in this upstream problem report http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45558

Comment 8 Fedora Update System 2010-09-07 12:33:11 UTC
gcc-4.5.1-3.fc14 has been submitted as an update for Fedora 14.
https://admin.fedoraproject.org/updates/gcc-4.5.1-3.fc14

Comment 9 Fedora Update System 2010-09-07 18:37:47 UTC
gcc-4.5.1-3.fc14 has been pushed to the Fedora 14 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update gcc'.  You can provide feedback for this update here: https://admin.fedoraproject.org/updates/gcc-4.5.1-3.fc14

Comment 10 Fedora Update System 2010-09-11 03:35:52 UTC
gcc-4.5.1-3.fc14 has been pushed to the Fedora 14 stable repository.  If problems still persist, please make note of it in this bug report.