public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/59761] New: ICE: g++ segfaults in test case involving constexpr default constructor with uninitialized member and template type alias
@ 2014-01-10 17:37 mizvekov at gmail dot com
  2014-01-10 17:42 ` [Bug c++/59761] " mizvekov at gmail dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: mizvekov at gmail dot com @ 2014-01-10 17:37 UTC (permalink / raw)
  To: gcc-bugs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="UTF-8", Size: 6127 bytes --]

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

            Bug ID: 59761
           Summary: ICE: g++ segfaults in test case involving constexpr
                    default constructor with uninitialized member and
                    template type alias
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mizvekov at gmail dot com

Created attachment 31803
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31803&action=edit
ICE/segfault when compiling this

Compiling the attached test_bad.cc with g++ results in an ICE, with the
following message:



test_bad.cc: In substitution of ‘template<bool B> using enable_if_t = typename
std::enable_if<B>::type [with bool B = is_foo0((*(const foo<0>*)(&
foo<0>())))]’:
test_bad.cc:12:22:   required from here
test_bad.cc:12:22: internal compiler error: Segmentation fault
 template<typename T, class = enable_if_t< is_foo0(T{}) >> int test() { return
0; }


               ^
This error only happens when both using the enable_if_t template type alias,
and struct foo having a data member uninitialized by the constexpr default
constructor.

If enable_if_t<...> is substituted by std::enable_if<...>::type, as in the
attached file test_good1.cc, then g++ rejects the code without any ICE. The
following is output:



test_good1.cc:12:36: error: no matching function for call to ‘test()’
 static const int fi = test<foo<0>>();
                                    ^
test_good1.cc:12:36: note: candidate is:
test_good1.cc:10:80: note: template<class T, class> int test()
 template<typename T, class = typename std::enable_if< is_foo0(T{})>::type> int
test() { return 0; }
                                                                               
^
test_good1.cc:10:80: note:   template argument deduction/substitution failed:
test_good1.cc:10:22: error: ‘constexpr foo<X>::foo() [with int X = 0]’ called
in a constant expression
 template<typename T, class = typename std::enable_if< is_foo0(T{})>::type> int
test() { return 0; }
                      ^
test_good1.cc:4:12: note: ‘constexpr foo<X>::foo() [with int X = 0]’ is not
usable as a constexpr function because:
  constexpr foo() {}
            ^
test_good1.cc:4:12: error: uninitialized member ‘foo<0>::bar’ in ‘constexpr’
constructor
test_good1.cc:10:22: note: in template argument for type ‘bool’ 
 template<typename T, class = typename std::enable_if< is_foo0(T{})>::type> int
test() { return 0; }
                      ^


If the code is modified so the default constructor leaves no members
uninitialized, as in the attached file test_good2.cc, then g++ accepts the
code.

Note that clang 3.4 quietly accepts all three versions, even with -Wall.

This is the version of g++ where the problem was found:

Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.8.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: /build/gcc/src/gcc-4.8-20131219/configure --prefix=/usr
--libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/
--enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared
--enable-threads=posix --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch
--disable-libssp --enable-gnu-unique-object --enable-linker-build-id
--enable-cloog-backend=isl --disable-cloog-version-check --enable-lto
--enable-plugin --enable-install-libiberty --with-linker-hash-style=gnu
--disable-multilib --disable-werror --enable-checking=release
Thread model: posix
gcc version 4.8.2 20131219 (prerelease) (GCC)
>From gcc-bugs-return-440004-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Fri Jan 10 17:40:08 2014
Return-Path: <gcc-bugs-return-440004-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 13020 invoked by alias); 10 Jan 2014 17:40:08 -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 13002 invoked by uid 48); 10 Jan 2014 17:40:04 -0000
From: "mizvekov at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/59761] ICE: g++ segfaults in test case involving constexpr default constructor with uninitialized member and template type alias
Date: Fri, 10 Jan 2014 17:40:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: c++
X-Bugzilla-Version: 4.8.2
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: mizvekov at gmail dot com
X-Bugzilla-Status: UNCONFIRMED
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: attachments.created
Message-ID: <bug-59761-4-J8zuaRd9s9@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-59761-4@http.gcc.gnu.org/bugzilla/>
References: <bug-59761-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-01/txt/msg01146.txt.bz2
Content-length: 344

http://gcc.gnu.org/bugzilla/show_bug.cgi?idY761

--- Comment #1 from Matheus Izvekov <mizvekov at gmail dot com> ---
Created attachment 31804
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id1804&actioníit
gcc rejects this, but without ICE

Same thing as test_bad.cc, except that std::enable_if is used directly instead
of enable_if_t


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

* [Bug c++/59761] ICE: g++ segfaults in test case involving constexpr default constructor with uninitialized member and template type alias
  2014-01-10 17:37 [Bug c++/59761] New: ICE: g++ segfaults in test case involving constexpr default constructor with uninitialized member and template type alias mizvekov at gmail dot com
@ 2014-01-10 17:42 ` mizvekov at gmail dot com
  2015-03-16 15:08 ` mpolacek at gcc dot gnu.org
  2015-06-23  8:47 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: mizvekov at gmail dot com @ 2014-01-10 17:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Matheus Izvekov <mizvekov at gmail dot com> ---
Created attachment 31805
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=31805&action=edit
gcc accepts this

This one is the same as test_bad.cc, except that the bar member of foo gets
initialized by the default constructor.


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

* [Bug c++/59761] ICE: g++ segfaults in test case involving constexpr default constructor with uninitialized member and template type alias
  2014-01-10 17:37 [Bug c++/59761] New: ICE: g++ segfaults in test case involving constexpr default constructor with uninitialized member and template type alias mizvekov at gmail dot com
  2014-01-10 17:42 ` [Bug c++/59761] " mizvekov at gmail dot com
@ 2015-03-16 15:08 ` mpolacek at gcc dot gnu.org
  2015-06-23  8:47 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: mpolacek at gcc dot gnu.org @ 2015-03-16 15:08 UTC (permalink / raw)
  To: gcc-bugs

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

Marek Polacek <mpolacek at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |ice-on-invalid-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-03-16
                 CC|                            |mpolacek at gcc dot gnu.org
   Target Milestone|---                         |4.8.5
     Ever confirmed|0                           |1

--- Comment #3 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
4.8 ICEs, 4.9/trunk work fine.


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

* [Bug c++/59761] ICE: g++ segfaults in test case involving constexpr default constructor with uninitialized member and template type alias
  2014-01-10 17:37 [Bug c++/59761] New: ICE: g++ segfaults in test case involving constexpr default constructor with uninitialized member and template type alias mizvekov at gmail dot com
  2014-01-10 17:42 ` [Bug c++/59761] " mizvekov at gmail dot com
  2015-03-16 15:08 ` mpolacek at gcc dot gnu.org
@ 2015-06-23  8:47 ` rguenth at gcc dot gnu.org
  2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2015-06-23  8:47 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
      Known to work|                            |4.9.0
         Resolution|---                         |FIXED
   Target Milestone|4.8.5                       |---
      Known to fail|                            |4.8.5

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.


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

end of thread, other threads:[~2015-06-23  8:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-10 17:37 [Bug c++/59761] New: ICE: g++ segfaults in test case involving constexpr default constructor with uninitialized member and template type alias mizvekov at gmail dot com
2014-01-10 17:42 ` [Bug c++/59761] " mizvekov at gmail dot com
2015-03-16 15:08 ` mpolacek at gcc dot gnu.org
2015-06-23  8:47 ` rguenth at gcc dot gnu.org

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