public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/97922] New: inline namespace caused confusing error message
@ 2020-11-20 2:28 harry.linxd at gmail dot com
2020-11-20 13:00 ` [Bug c++/97922] " redi at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: harry.linxd at gmail dot com @ 2020-11-20 2:28 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97922
Bug ID: 97922
Summary: inline namespace caused confusing error message
Product: gcc
Version: 10.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: harry.linxd at gmail dot com
Target Milestone: ---
For a type that's defined in inline namespace, forward declaration and
definition appear in the same scope cause confusing error messages, while
clang++'s diagnostic messages are more clear
```
$cat type1.h
namespace test {
inline namespace internal {
struct Type1 {
Type1() = default;
};
}
}
```
```
$cat test.cpp
#include <utility>
#include "./type1.h"
namespace test {
struct Type1; //Type1 is actually in an inline namespace
}
using Type = std::pair<test::Type1, int>;
void f(Type& t);
```
```
$ g++ -I. test.cpp
test.cpp:8:40: error: template argument 1 is invalid
8 | using Type = std::pair<test::Type1, int>;
| ^
test.cpp:10:6: error: variable or field 'f' declared void
10 | void f(Type& t);
| ^
test.cpp:10:8: error: 'Type' was not declared in this scope
10 | void f(Type& t);
| ^~~~
test.cpp:10:14: error: 't' was not declared in this scope
10 | void f(Type& t);
| ^
```
Here gcc's error message is sort of confusing, while clang's diagnostic message
is more straight:
```
$ clang++ -I. test.cpp
test.cpp:8:30: error: reference to 'Type1' is ambiguous
using Type = std::pair<test::Type1, int>;
^
././type1.h:3:8: note: candidate found by name lookup is
'test::internal::Type1'
struct Type1 {
^
test.cpp:5:8: note: candidate found by name lookup is 'test::Type1'
struct Type1;
^
1 error generated.
```
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/97922] inline namespace caused confusing error message
2020-11-20 2:28 [Bug c++/97922] New: inline namespace caused confusing error message harry.linxd at gmail dot com
@ 2020-11-20 13:00 ` redi at gcc dot gnu.org
2020-11-20 13:02 ` redi at gcc dot gnu.org
2021-12-14 5:47 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2020-11-20 13:00 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97922
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed| |2020-11-20
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/97922] inline namespace caused confusing error message
2020-11-20 2:28 [Bug c++/97922] New: inline namespace caused confusing error message harry.linxd at gmail dot com
2020-11-20 13:00 ` [Bug c++/97922] " redi at gcc dot gnu.org
@ 2020-11-20 13:02 ` redi at gcc dot gnu.org
2021-12-14 5:47 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2020-11-20 13:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97922
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Reduced:
namespace test {
inline namespace internal {
struct Type1 { };
}
}
namespace test {
struct Type1; //Type1 is actually in an inline namespace
}
template<typename> struct P { };
using Type = P<test::Type1>;
void f(Type& t);
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c++/97922] inline namespace caused confusing error message
2020-11-20 2:28 [Bug c++/97922] New: inline namespace caused confusing error message harry.linxd at gmail dot com
2020-11-20 13:00 ` [Bug c++/97922] " redi at gcc dot gnu.org
2020-11-20 13:02 ` redi at gcc dot gnu.org
@ 2021-12-14 5:47 ` pinskia at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-12-14 5:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97922
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Dup of bug 79070 really.
*** This bug has been marked as a duplicate of bug 79070 ***
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-12-14 5:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-20 2:28 [Bug c++/97922] New: inline namespace caused confusing error message harry.linxd at gmail dot com
2020-11-20 13:00 ` [Bug c++/97922] " redi at gcc dot gnu.org
2020-11-20 13:02 ` redi at gcc dot gnu.org
2021-12-14 5:47 ` pinskia at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).