Bug 14510 - [3.4/4.0 Regression] Lookup error between function name and struct name
Summary: [3.4/4.0 Regression] Lookup error between function name and struct name
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.4.0
: P1 critical
Target Milestone: 3.4.0
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
: 14509 (view as bug list)
Depends on:
Blocks: 12944
  Show dependency treegraph
 
Reported: 2004-03-10 06:55 UTC by Peter Schmid
Modified: 2004-10-30 21:11 UTC (History)
2 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work: 3.3.3
Known to fail: 3.4.0 4.0.0
Last reconfirmed: 2004-03-10 12:11:42


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Schmid 2004-03-10 06:55:26 UTC
I believe that there is no second declaration of the struct t_bind in the 
following example. Therefore a rejection of the source code is not warranted. I 
guess this is a regression. This example is taken from the current Ace 
distribution. 
 
g++ -v s.C 
Reading specs from /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/specs 
Configured with: ../gcc/configure --enable-threads=posix --enable-languages=c,c
++,f77,objc --enable-__cxa_atexit --enable-libstdcxx-debug 
Thread model: posix 
gcc version 3.4.0 20040309 (prerelease) 
 /usr/local/libexec/gcc/i686-pc-linux-gnu/3.4.0/cc1plus -quiet -v -D_GNU_SOURCE 
s.C -quiet -dumpbase s.C -mtune=pentiumpro -auxbase s -version -o /tmp/
ccUovTPT.s 
ignoring nonexistent directory "NONE/include" 
ignoring nonexistent directory "/usr/local/lib/gcc/
i686-pc-linux-gnu/3.4.0/../../../../i686-pc-linux-gnu/include" 
#include "..." search starts here: 
#include <...> search starts here: 
 /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0 
 /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/
i686-pc-linux-gnu 
 /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/../../../../include/c++/3.4.0/
backward 
 /usr/local/include 
 /usr/local/lib/gcc/i686-pc-linux-gnu/3.4.0/include 
 /usr/include 
End of search list. 
GNU C++ version 3.4.0 20040309 (prerelease) (i686-pc-linux-gnu) 
        compiled by GNU C version 3.4.0 20040309 (prerelease). 
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64274 
s.C:8: error: conflicting declaration 'struct t_bind' 
s.C:1: error: 'struct t_bind' has a previous declaration as `struct t_bind' 
s.C:8: error: `int ACE_OS::t_bind(t_bind*)' should have been declared inside 
`ACE_OS' 
 
source code s.C 
struct t_bind { }; 
 
namespace ACE_OS 
{ 
  extern int t_bind (struct t_bind *req); 
} 
 
inline int ACE_OS::t_bind (struct t_bind *req) { }
Comment 1 Giovanni Bajo 2004-03-10 12:11:42 UTC
Yes, a regression on the mainline and the 3.4 branch. Alas, it looks like it's 
too late to get this fixed before 3.4.0.
Comment 2 Giovanni Bajo 2004-03-10 12:16:12 UTC
*** Bug 14509 has been marked as a duplicate of this bug. ***
Comment 3 Andrew Pinski 2004-03-10 14:49:46 UTC
Here is something smaller:
struct c{ };
namespace A
{
  int c(struct c*req);
}
int A::c(struct c*req) { }
It looks like it is trying to look up the struct c in the namespace even though there is one at the global 
scope.

Mark, I feel that this bug should targeted towards 3.4.0 as it blocks ACE which is on the Criteria page 
for 3.3 and is on the draft of the Criteria page for 3.4.0.
Comment 5 CVS Commits 2004-03-11 04:25:42 UTC
Subject: Bug 14510

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	mmitchel@gcc.gnu.org	2004-03-11 04:25:40

Modified files:
	gcc/testsuite  : ChangeLog 
	gcc/cp         : ChangeLog decl.c 
Added files:
	gcc/testsuite/g++.dg/lookup: struct2.C 

Log message:
	PR c++/14510
	* decl.c (xref_tag): Disregard non-type declarations when
	looking up a tagged type.
	
	PR c++/14510
	* g++.dg/lookup/struct2.C: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3593&r2=1.3594
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/lookup/struct2.C.diff?cvsroot=gcc&r1=1.1&r2=1.2
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3993&r2=1.3994
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/decl.c.diff?cvsroot=gcc&r1=1.1193&r2=1.1194

Comment 6 Mark Mitchell 2004-03-11 04:27:27 UTC
Fixed in GCC 3.4 and GCC 3.5.
Comment 7 Mark Mitchell 2004-03-11 04:27:43 UTC
Fixed in GCC 3.4 and GCC 3.5.