From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 82606 invoked by alias); 10 Jul 2015 13:19:17 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 82592 invoked by uid 89); 10 Jul 2015 13:19:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 10 Jul 2015 13:19:15 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 7E3FA388851 for ; Fri, 10 Jul 2015 13:19:14 +0000 (UTC) Received: from redhat.com (ovpn-204-71.brq.redhat.com [10.40.204.71]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t6ADJAn8010934 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Fri, 10 Jul 2015 09:19:13 -0400 Date: Fri, 10 Jul 2015 13:19:00 -0000 From: Marek Polacek To: GCC Patches Subject: RFC: Use std::{min,max} instead of MIN/MAX? Message-ID: <20150710131910.GB2876@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.5.23 (2014-03-12) X-SW-Source: 2015-07/txt/msg00886.txt.bz2 Uros had the idea of using std::min/max instead of our MIN/MAX macros defined in system.h. I thought I would do this cleanup, but very soon I ran into a problem of failed template argument substitution: std::min/max function templates require that both arguments be of the same type: /home/marek/src/gcc/gcc/caller-save.c: In function ‘void replace_reg_with_saved_mem(rtx_def**, machine_mode, int, void*)’: /home/marek/src/gcc/gcc/caller-save.c:1151:63: error: no matching function for call to ‘min(int, short unsigned int)’ offset -= (std::min (UNITS_PER_WORD, GET_MODE_SIZE (mode)) ^ In file included from /usr/include/c++/5.1.1/bits/char_traits.h:39:0, from /usr/include/c++/5.1.1/string:40, from /home/marek/src/gcc/gcc/system.h:201, from /home/marek/src/gcc/gcc/caller-save.c:21: /usr/include/c++/5.1.1/bits/stl_algobase.h:195:5: note: candidate: template const _Tp& std::min(const _Tp&, const _Tp&) min(const _Tp& __a, const _Tp& __b) ^ /usr/include/c++/5.1.1/bits/stl_algobase.h:195:5: note: template argument deduction/substitution failed: /home/marek/src/gcc/gcc/caller-save.c:1151:63: note: deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘short unsigned int’) offset -= (std::min (UNITS_PER_WORD, GET_MODE_SIZE (mode)) We can work around this by using casts, but that seems too ugly a solution. So it appears to me that we're stuck with our MIN/MAX macros. Thoughts? Marek