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

            Bug ID: 92974
           Summary: diagnostic missing source information
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: barry.revzin at gmail dot com
  Target Milestone: ---

Here's the best reduction I was able to come up with thanks to creduce:

# 1 "" 3
typedef unsigned char a;
typedef unsigned b;
enum {
  c
};
class d { 
public:
  template <typename e> int f(e const &, a const *, b); 
};
template <typename e> d::f(e const &, a const *, b) { b g(c ?: g); }
int h;
unsigned char i;
long j;
class k { 
  l() { m.f(h, &i, j); }
  d m;
};


If you compile that snipped with -Wall -Wextra, you get:

: In instantiation of ‘int d::f(const e&, const a*, b) [with e = int; a =
unsigned char; b = unsigned int]’:
:15:21:   required from here
cc1plus: warning: enumeral and non-enumeral type in conditional expression
[-Wextra]

The warning comes from cc1plus and has no source information attached to it.
The comparison is on line 11, but the source printed is line 15 - which is the
declaration of "class k".

The kind of diagnostic I'd expect is (from a different reduction):

reduction.cpp:4:21: warning: enumeral and non-enumeral type in conditional
expression [-Wextra]
    4 | void b() { long c(a ?: c); }
      |                   ~~^~~~

That is, actually pointing me to _where_ the comparison happens.

Reply via email to