public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "miyuki at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/66572] New: [6 Regression] Bogus Wlogical-op warning for operands coming from template instantiations
Date: Wed, 17 Jun 2015 14:45:00 -0000	[thread overview]
Message-ID: <bug-66572-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 66572
           Summary: [6 Regression] Bogus Wlogical-op warning for operands
                    coming from template instantiations
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: miyuki at gcc dot gnu.org
  Target Milestone: ---

Consider this example:

$ cat ./test.cc 
struct false_type
{
    static constexpr bool value = false;
};

struct true_type
{
    static constexpr bool value = true;
};

template<typename T>
struct is_unsigned : false_type {};

template<>
struct is_unsigned<unsigned> : true_type {};

template<typename T1, typename T2>
bool foo()
{
    return is_unsigned<T1>::value && is_unsigned<T2>::value;
}

int main()
{
    foo<unsigned, unsigned>();
}

$ g++ -Wlogical-op -std=c++11 ./test.cc 
./test.cc: In instantiation of 'bool foo() [with T1 = unsigned int; T2 =
unsigned int]':
./test.cc:25:29:   required from here
./test.cc:20:35: warning: logical 'and' of equal expressions [-Wlogical-op]
     return is_unsigned<T1>::value && is_unsigned<T2>::value;

IMHO GCC should not issue this warning: in this instantiation
(is_unsigned<unsigned>::value && is_unsigned<unsigned>::value) operator && is
indeed redundant, but that is not true for general case.


             reply	other threads:[~2015-06-17 14:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-17 14:45 miyuki at gcc dot gnu.org [this message]
2015-06-17 16:47 ` [Bug c++/66572] " manu at gcc dot gnu.org
2015-06-17 18:00 ` miyuki at gcc dot gnu.org
2015-06-18  1:05 ` miyuki at gcc dot gnu.org
2015-07-23 18:58 ` mpolacek at gcc dot gnu.org
2015-07-23 18:59 ` mpolacek at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-66572-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).