[Bug c++/44580] New: inconsistent "right-hand operand of comma has no effect"

akim dot demaille at gmail dot com gcc-bugzilla@gcc.gnu.org
Fri Jun 18 11:47:00 GMT 2010


I have observed the following behavior on several generations of GCC (starting
at Apple's 4.0) and up to 4.6.  Tested on OS X, but also GNU/Linux.

It's hard to write assert-like functions because GCC does not behave equally
when the context is that of a function template, or a simple function.

This passes with -Wall:

static
void
unreachable_1()
{
  return;
  (abort(), 0);
}

but this does not:

template <typename T>
static
void
unreachable_2(T)
{
  return;
  (abort(), 0);
}

$ g++-4.0 unreachable.cc -Wall
unreachable.cc: In function ‘void unreachable_2(T)’:
unreachable.cc:19: warning: right-hand operand of comma has no effect
unreachable.cc: In function ‘void unreachable_2(T) [with T = int]’:
unreachable.cc:26:   instantiated from here
unreachable.cc:19: warning: right-hand operand of comma has no effect

$ g++-mp-4.6 unreachable.cc -Wall
unreachable.cc: In function 'void unreachable_2(T) [with T = int]':
unreachable.cc:26:18:   instantiated from here
unreachable.cc:19:3: warning: right-hand operand of comma has no effect
[-Wunused-value]


-- 
           Summary: inconsistent "right-hand operand of comma has no effect"
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: akim dot demaille at gmail dot com


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



More information about the Gcc-bugs mailing list