Bug 36659 - Confusing error message order 'error: ‘functionname’ declared as an ‘inline’ variable'
Summary: Confusing error message order 'error: ‘functionname’ declared as an ‘inline’ ...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.4
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2008-06-28 14:20 UTC by Carlo Wood
Modified: 2011-10-14 14:13 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.4.0
Last reconfirmed: 2008-06-28 21:25:32


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Carlo Wood 2008-06-28 14:20:15 UTC
The order of the error messages

error: ‘functionname’ declared as an ‘inline’ variable

and

error: ‘UnDefinedClass’ was not declared in this scope

should be swapped.

See following testcase:

struct A {};
int functionname(A foo);

inline int functionname(UnDefinedClass foo)
{
  return 0;
}

which results in the errors:

hikaru:~>g++ -c troep.cc
troep.cc:4: error: ‘functionname’ declared as an ‘inline’ variable
troep.cc:4: error: ‘int functionname’ redeclared as different kind of symbol
troep.cc:2: error: previous declaration of ‘int functionname(A)’
troep.cc:4: error: ‘UnDefinedClass’ was not declared in this scope

A much better or would be:

troep.cc:4: error: ‘UnDefinedClass’ was not declared in this scope
troep.cc:4: error: ‘functionname’ declared as an ‘inline’ variable
troep.cc:4: error: ‘int functionname’ redeclared as different kind of symbol
troep.cc:2: error: previous declaration of ‘int functionname(A)’
Comment 1 Richard Biener 2008-06-28 21:25:32 UTC
Confirmed.
Comment 2 Dan Horák 2010-11-15 11:08:36 UTC
Still present in 4.5.1, real world example from building xulrunner 2.0 on Fedora/s390x


jsval.h:524:22: error: 'JSVAL_IS_DOUBLE_IMPL' declared as an 'inline' variable
jsval.h:524:22: warning: 'always_inline' attribute ignored
jsval.h:524:22: error: 'jsval_layout' was not declared in this scope
jsval.h:525:1: error: expected ',' or ';' before '{' token
jsval.h:529:25: error: 'jsval_layout' does not name a type
Comment 3 Don 2011-10-14 13:06:51 UTC
Found this bug while trying to compile Spidermonkey 1.85 with gcc 4.6 (g++).  nanojit.h:183:26: error: 'isS32' declared as an 'inline' variable.  The code is:

static inline bool isS32(intptr_t i) {
    return int32_t(i) == i;
}

Is there a fix for this or is this version flawed?  Can we be certain this bug will be fixed by the next release?
Comment 4 Don 2011-10-14 13:11:09 UTC
Found this bug while trying to compile Spidermonkey 1.85 with gcc 4.6 (g++).  nanojit.h:183:26: error: 'isS32' declared as an 'inline' variable.  The code is:

static inline bool isS32(intptr_t i) {
    return int32_t(i) == i;
}

Is there a fix for this or is this version flawed?  Can we be certain this bug will be fixed by the next release?  This is a basic declaration and should work.
Comment 5 Jonathan Wakely 2011-10-14 13:14:34 UTC
(In reply to comment #4)
> Is there a fix for this or is this version flawed?  Can we be certain this bug
> will be fixed by the next release?  This is a basic declaration and should
> work.

Read the bugzilla report.  

It's not a bug, it's an enhancement request for a better error message.  The
compiler is correct to reject your code, but it could print a more helpful
message.

Your problem appears to be caused by failing to #include <stdint.h>, not a compiler bug.
Comment 6 Don 2011-10-14 14:13:59 UTC
Yeah.., soon realized that after looking into it.  Thanks.