Bug 35138 - [4.3 Regression] g++ rejects valid code
Summary: [4.3 Regression] g++ rejects valid code
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.3.0
: P1 normal
Target Milestone: 4.3.0
Assignee: Jakub Jelinek
URL:
Keywords: rejects-valid
: 35139 (view as bug list)
Depends on:
Blocks: 32384
  Show dependency treegraph
 
Reported: 2008-02-08 13:30 UTC by tim blechmann
Modified: 2008-02-13 22:32 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.1.2 4.2.2
Known to fail: 4.3.0
Last reconfirmed: 2008-02-12 20:14:24


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tim blechmann 2008-02-08 13:30:09 UTC
g++-4.3 rejects the following code:

namespace n1 {
struct foo{};
}

namespace n2 {
struct foo{};
}

using namespace n1;
using namespace n2;

template <typename tp>
int run(tp const & t) {
    return t.foo;
}

struct bar {
    int foo;
};

int main() {
    bar b;

    run(b);
}

the error message is:
bug.cpp: In function ‘int run(const tp&)’:
bug.cpp:14: error: reference to ‘foo’ is ambiguous
bug.cpp:6: error: candidates are: struct n2::foo
bug.cpp:2: error:                 struct n1::foo

g++-4.1 and g++-4.2 accept the code, though ...
Comment 1 tim blechmann 2008-02-08 14:01:10 UTC
*** Bug 35139 has been marked as a duplicate of this bug. ***
Comment 2 Richard Biener 2008-02-08 16:11:14 UTC
Confirmed.
Comment 3 Jakub Jelinek 2008-02-08 17:58:32 UTC
Caused by my http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129836
This is during tentative parse, so I guess the errors should be suppressed.
Comment 4 Wolfgang Bangerth 2008-02-08 21:51:28 UTC
This should get higher priority than P3...
Comment 5 Richard Biener 2008-02-08 22:15:58 UTC
This is worse than PR32384, so either we have a fix for it or we should revert
the fix for PR32384 before 4.3.0.
Comment 6 Jakub Jelinek 2008-02-11 23:11:21 UTC
cp_parser_class_name since PR20293 errors unconditionally even during tentative parse.  Mark, is there a way to get a silent tentative parse of the optional
nested name specifier plus typename?  Or is trying to parse it tentatively
as pseudo-dtor followed by parsing it as id-expression/member access if the former just never going to work?
Comment 8 Jakub Jelinek 2008-02-13 22:31:34 UTC
Subject: Bug 35138

Author: jakub
Date: Wed Feb 13 22:30:43 2008
New Revision: 132298

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=132298
Log:
	PR c++/35138
	* parser.c (cp_parser_pseudo_destructor_name): If next tokens
	are not identifier :: ~, return before calling cp_parser_type_name.

	* g++.dg/template/member8.C: New test.

Added:
    trunk/gcc/testsuite/g++.dg/template/member8.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog

Comment 9 Jakub Jelinek 2008-02-13 22:32:48 UTC
Fixed.