https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122001

            Bug ID: 122001
           Summary: [16 Regression] confusing 'required from here'
                    placement
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: diagnostics
          Assignee: dmalcolm at redhat dot com
          Reporter: nshead at gcc dot gnu.org
  Target Milestone: ---

The following C++ code:

  template <typename T>
  void foo(T t) {
    1 + t;
  }

  int main() {
    foo(nullptr);
  }

GCC 15 emitted the following error:

<source>: In instantiation of 'void foo(T) [with T = std::nullptr_t]':
<source>:7:8:   required from here
    7 |     foo(nullptr);
      |     ~~~^~~~~~~~~
<source>:3:7: error: invalid operands of types 'int' and 'std::nullptr_t' to
binary 'operator+'
    3 |     1 + t;
      |     ~~^~~

But since GCC 16 we emit:

<source>: In instantiation of 'void foo(T) [with T = std::nullptr_t]':
required from here
<source>:7:8:   
    7 |     foo(nullptr);
      |     ~~~^~~~~~~~~
<source>:3:7: error: invalid operands of types 'int' and 'std::nullptr_t' to
binary 'operator+'
    3 |     1 + t;
      |     ~~^~~

Note that the "required from here" line is now floating on a line by itself,
with the source reference and location placed separately on a following line. 
Especially in more complex examples this can be somewhat confusing to follow
(and IMO at least looks a bit ugly).

Reply via email to