Bug 111885 - [14 Regression] source code after "required from here" note sometimes printed strangely
Summary: [14 Regression] source code after "required from here" note sometimes printed...
Status: RESOLVED MOVED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 14.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks:
 
Reported: 2023-10-19 20:59 UTC by Patrick Palka
Modified: 2023-10-19 23:59 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Palka 2023-10-19 20:59:50 UTC
$ cat required-from-here-bug.C
template<class T> void f(typename T::type);

int main() {
  f<int>(0);
}

$ g++ required-from-here-bug.C
required-from-here-bug.C: In function ‘int main()’:
required-from-here-bug.C:4:9: error: no matching function for call to ‘f<int>(int)’
    4 |   f<int>(0);
      |   ~~~~~~^~~
required-from-here-bug.C:1:24: note: candidate: ‘template<class T> void f(typename T::type)’
    1 | template<class T> void f(typename T::type);
      |                        ^
required-from-here-bug.C:1:24: note:   template argument deduction/substitution failed:
required-from-here-bug.C: In substitution of ‘template<class T> void f(typename T::type) [with T = int]’:
required-from-here-bug.C:4:9:   required from here
required-from-here-bug.C:1:24: note:     4 |   f<int>(0);
required-from-here-bug.C:1:24: note:       |   ~~~~~~^~~
required-from-here-bug.C:1:24: error: ‘int’ is not a class, struct, or union type
    1 | template<class T> void f(typename T::type);
      |                        ^

The two notes following the "required from here" diagnostic seem to be misprinted -- they refer to line 1, but show source code from line 4, which seems like a bug?
Comment 1 Patrick Palka 2023-10-19 23:59:30 UTC
On second thought I reckon I'll just note this observation in the patch email thread instead, sorry for the noise...