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++/83591] New: -Wduplicated-branches fires in system headers in template instantiation


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

            Bug ID: 83591
           Summary: -Wduplicated-branches fires in system headers in
                    template instantiation
           Product: gcc
           Version: 7.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: TonyELewis at hotmail dot com
  Target Milestone: ---

Compiling with:


g++ -Werror -Wduplicated-branches -c -isystem sysheaddir b.cpp


where b.cpp is :


#include "a.hpp"


...and sysheaddir/a.hpp is:


template <class...>
void f() {
        int b;
        ( b ? b : b );
}

void g() {
        f<>();
}


...gives:


sysheaddir/a.hpp:8:6:   required from here
cc1plus: error: this condition has identical branches
[-Werror=duplicated-branches]
cc1plus: all warnings being treated as errors


Thought the code *does* have duplicate branches, I see two problems with this:
 * the warning is firing even though all the code relevant to the warning is in
a system header
 * the warning doesn't provide the line number on which the identical branches
appear

I suspect that it's already the intended design that this warning shouldn't
fire in system headers. Indeed, if I add a simple `void h() { int b; b ? b : b;
}` into b.cpp, it triggers the warning but if I add it to the system header
sysheaddir/a.hpp, it doesn't.


I'm using g++ (Ubuntu 7.2.0-8ubuntu3) 7.2.0. It looks to me from using
godbolt.org, that the same problems persist in trunk (8.0.0 20171225).


I suspect this is related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82541
but it has differences:
 * I'm highlighting a true positive warning in a *system* header (rather than a
false positive in the .cpp file)
 * I'm highlighting the lack of line number in the warning message

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