public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/63723] New: Narrowing conversion allowed in braced init list in SFINAE context
@ 2014-11-03 14:45 tavianator at gmail dot com
  2014-11-03 15:42 ` [Bug c++/63723] " manu at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: tavianator at gmail dot com @ 2014-11-03 14:45 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 63723
           Summary: Narrowing conversion allowed in braced init list in
                    SFINAE context
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tavianator at gmail dot com

Created attachment 33877
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=33877&action=edit
Preprocessed source

GCC allows narrowing conversions in braced init lists with only a warning.  The
documentation suggests that this extension doesn't apply in SFINAE contexts,
but it appears to be wrong:

$ cat foo.cpp
#include <type_traits>
#include <utility>

template <typename From, typename To>
class is_list_convertible_helper
{
  template <typename To2>
  static void requires_conversion(To2 t);

  template <typename From2, typename To2,
      typename = decltype(requires_conversion<To2>({std::declval<From2>()}))>
  //                                               ^ Braced initializer
  static std::true_type helper(int);

  template <typename From2, typename To2>
  static std::false_type helper(...);

public:
  using type = decltype(helper<From, To>(0));
};

template <typename From, typename To>
class is_list_convertible
  : public is_list_convertible_helper<From, To>::type
{ };

static_assert(!is_list_convertible<double, int>::value,
    "double -> int is narrowing!");

$ g++ -std=c++11 foo.cpp
foo.cpp: In substitution of ‘template<class From2, class To2, class> static
std::true_type is_list_convertible_helper<From, To>::helper(int) [with From2 =
double; To2 = int; <template-parameter-1-3> = <missing>]’:
foo.cpp:18:31:   required from ‘class is_list_convertible_helper<double, int>’
foo.cpp:22:7:   required from ‘class is_list_convertible<double, int>’
foo.cpp:26:48:   required from here
foo.cpp:10:46: warning: narrowing conversion of ‘std::declval<double>()’ from
‘double’ to ‘int’ inside { } [-Wnarrowing]
       typename = decltype(requires_conversion<To2>({std::declval<From2>()}))>
                                              ^
foo.cpp:26:1: error: static assertion failed: double -> int is narrowing!
 static_assert(!is_list_convertible<double, int>::value,
 ^
>From gcc-bugs-return-465650-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Mon Nov 03 15:30:54 2014
Return-Path: <gcc-bugs-return-465650-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 12877 invoked by alias); 3 Nov 2014 15:30:53 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 12816 invoked by uid 55); 3 Nov 2014 15:30:49 -0000
From: "dave.anglin at bell dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/63691] GCC 4.9.x fails to build GLIBC 2.20 on HPPA
Date: Mon, 03 Nov 2014 15:30:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: target
X-Bugzilla-Version: 4.9.0
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: dave.anglin at bell dot net
X-Bugzilla-Status: REOPENED
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-63691-4-RQCNmp4HcF@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-63691-4@http.gcc.gnu.org/bugzilla/>
References: <bug-63691-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2014-11/txt/msg00122.txt.bz2
Content-length: 444

https://gcc.gnu.org/bugzilla/show_bug.cgi?idc691

--- Comment #12 from dave.anglin at bell dot net ---
On 10/31/2014 5:30 PM, aaro.koskinen at iki dot fi wrote:
> I was able to isolate the problem to GLIBC elf/dl-conflict.c and specifically
> hppa specific elf_machine_rela function called from there.
Could you isolate the "wrong code" in elf/dl-conflict.c?  It seems a null
pointer check in this object is being incorrectly removed.

Dave


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-12-19  6:02 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-03 14:45 [Bug c++/63723] New: Narrowing conversion allowed in braced init list in SFINAE context tavianator at gmail dot com
2014-11-03 15:42 ` [Bug c++/63723] " manu at gcc dot gnu.org
2014-11-03 16:14 ` tavianator at gmail dot com
2014-11-03 19:22 ` daniel.kruegler at googlemail dot com
2014-11-04 14:57 ` tavianator at gmail dot com
2014-12-18 23:58 ` paolo.carlini at oracle dot com
2014-12-19  0:02 ` paolo at gcc dot gnu.org
2014-12-19  0:04 ` paolo.carlini at oracle dot com
2014-12-19  6:02 ` tavianator at gmail dot com

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).