This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/59293] New: Bogus -Wsign-compare warning when using typeof() on a constant


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59293

            Bug ID: 59293
           Summary: Bogus -Wsign-compare warning when using typeof() on a
                    constant
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: shawn at churchofgit dot com

#define MAX(a,b)                                 \
        __extension__ ({                         \
                        typeof(a) _a = (a);      \
                        typeof(b) _b = (b);      \
                        _a > _b ? _a : _b;       \
                })

int main() {
    if (MAX(5, (unsigned)3))
        return 1;
    return 0;
}


gives:
excessive_signed_compare.c:5:28: warning: comparison between signed and
unsigned integer expressions [-Wsign-compare]
                         _a > _b ? _a : _b;       \
                            ^
excessive_signed_compare.c:9:6: note: in expansion of macro âMAXâ
  if (MAX(5, (unsigned)3))
      ^
excessive_signed_compare.c:5:38: warning: signed and unsigned type in
conditional expression [-Wsign-compare]
                         _a > _b ? _a : _b;       \

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]