Menu

#208 Wrongful compiler error

closed
gcc (462)
2014-07-31
2002-11-02
No

When compiling the attached file, using this command:

c:\mingw\bin\g++ -O2 -ftemplate-depth-500 -o
cpp_grammar.o -c cpp_grammar.ii

I get an error in a piece of code that looks like this:

---
struct cpp_grammar: grammar<cpp_grammar> {

...

template <typename ScannerT>
struct definition:
cpp_expressions<ScannerT>
{
...
template < typename ParserT >
struct brace_block_functor {
...
};

template < typename ParserT >
static
functor_parser<brace_block_functor<ParserT> > //
line 2304
brace_block(ParserT const& parser) {
return brace_block_functor<ParserT>(parser);
};
...
};
...
};
---

The error (sans the "instantiated from" super-spew) says
this:

---
cpp_grammar.cpp:2306: type/value mismatch at
argument 1 in template parameter
list for `template<class FunctorT> struct
spirit::functor_parser'
cpp_grammar.cpp:2306: expected a type, got
`brace_block_functor'
cpp_grammar.cpp:2306: confused by earlier errors,
bailing out
---

This is patently wrong. In fact, I have a CygWin with
GCC 3.0.3 that compiles this program perfectly.

This is with the newest MinGW: 2.0.0-3

Discussion

  • Juan Carlos Arevalo-Baeza

    Logged In: YES
    user_id=447726

    I couldn't attach the file (the program is BIG, so it would not
    be accepted, not even zipped).

    You can download it from here:

    http://home.JCABs-Rumblings.com/ftp/cpp_grammar_error.zip

    The ZIP file includes the source, preprocessed source and
    the error spew.

    Also, the line marked as 2304 in the source fragment I sent
    should be the line of the error: 2306. Copy-paste typo.

     
  • Danny Smith

    Danny Smith - 2002-11-02
    • status: open --> pending
     
  • Danny Smith

    Danny Smith - 2002-11-02

    Logged In: YES
    user_id=11494

    Add -D__GTTHREAD_HIDE_WIN32API to command line
    (or put define in appropriate Boost config header). I
    have just built the c_grammar example app from spriit-
    1.5.1 with that define and succeeded. (with warning
    about unknown compiler).

    The problem is pollution with names from w32 api. I
    suspect one of the Token names.

    __GTTHREAD_HIDE_WIN32API will be defined by default
    in future mingw releases.

    I'll change status of bug report to pending, until the
    define is put into FSF sources.

    Danny
    Danny

     
  • Juan Carlos Arevalo-Baeza

    Logged In: YES
    user_id=447726

    Danny,

    I just tried with your fix:

    c:\mingw\bin\g++ -O2 -ftemplate-depth-500 -o
    cpp_grammar.o -c cpp_grammar.ii -
    D__GTTHREAD_HIDE_WIN32API

    And it still shows the error.

    Note that this is NOT the c_grammar sample of Spirit. It's
    based on it, yes, but the error happens on new code.

    Thanks for checking, though.

     
  • Juan Carlos Arevalo-Baeza

    • status: pending --> open
     
  • Danny Smith

    Danny Smith - 2002-11-03

    Logged In: YES
    user_id=11494

    There was a typo in my last message. The define should
    be:
    __GTHREAD_HIDE_WIN32API

    (not __GTTHREAD_HIDE_WIN32API).

    I'll test again with your cpp_grammar.cpp and spirit
    headers

    BTW, you won't be able to test the preprocessor define
    with a preprocessed file. :)

    Danny

     
  • Juan Carlos Arevalo-Baeza

    Logged In: YES
    user_id=447726

    Ok, Danny, sorry for the confusion(s). O:-)

    So I tried:

    c:\mingw\bin\g++ -O2 -ftemplate-depth-500 -o
    cpp_grammar.exe cpp_grammar.cpp -I g:\JCAB\Spirit -
    D__GTHREAD_HIDE_WIN32API

    Still shows the error.

    Salutaciones,
    JCAB

     
  • Danny Smith

    Danny Smith - 2002-11-03

    Logged In: YES
    user_id=11494

    Okay, the Win32 api business has nothing to do with
    this.

    I don't believe this is a mingw-specific bug though. I've
    attached my err.log using yesterday's GCC 3.3 (without
    any mingw local patches) .

    The first problem is at line 1022.:
    cpp_grammar.cpp: In member function `TokenID
    TokenDB::add(const char*, TokenID)
    ':
    cpp_grammar.cpp:1022: error: non-lvalue in unary `&'
    cpp_grammar.cpp:1022: error: no match for call to `
    (const
    spirit::symbol_inserter<TokenID,
    spirit::impl::tst<TokenID, char> >) (const
    char*&, TokenID&)'
    d:/develop/spirit-
    1.5.1/boost/spirit/symbols/symbols.hpp:211: error:
    candidates
    are: const spirit::symbol_inserter<T, SetT>&
    spirit::symbol_inserter<T,
    SetT>::operator()(const CharT*, const T& = T()) const
    [with CharT = char, T
    = TokenID, SetT = spirit::impl::tst<TokenID, char>]

    and in the end cc1plus ICES.

    I don't have time at the moment to try to understand the
    spirit package, but if you really think this is a bug in
    the compiler, you may want to report to gcc-bugs.

    Danny

     
  • Danny Smith

    Danny Smith - 2002-11-03

    compiler error log

     
  • Juan Carlos Arevalo-Baeza

    Logged In: YES
    user_id=447726

    Error filed on GCC's GNATSWEB: c++/8442

    Thanx, Danny.

     
  • Earnie Boyd

    Earnie Boyd - 2003-01-03
    • status: open --> closed