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++/11945] New: Incorrect warnings issued for comma-expressions inside templates


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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

           Summary: Incorrect warnings issued for comma-expressions inside
                    templates
           Product: gcc
           Version: 3.4
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: gerald at pfeifer dot com
                CC: gcc-bugs at gcc dot gnu dot org

This bug only happens inside a template class or a template function,
but not inside a regular function.

Compile the following with g++ -W

  extern "C" void FormatDisk();
  template <class T>
  struct C {
    C(){ FormatDisk(), 0; }  // extraneous warning
  };
  template <class T>
  void f() { FormatDisk(), 0; } // extraneious warning
  void g() { FormatDisk(), 0; }

Incorrect warnings (Formatting a disk _is_ an effect, isn't it)?
  x.cc: In constructor `C<T>::C()':
  x.cc:4: warning: left-hand operand of comma expression has no effect
  x.cc: In function `void f()':
  x.cc:7: warning: left-hand operand of comma expression has no effect

This is a regression introduced around 2003-07-08, probably by Mark (according
to educated guesses using ChangeLogs and `cvs annotate`).

It is especially bad, as Solaris system headers use constructs like this.


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