public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/51878] New: ICE or OOM with decltype + variadic templates + "indirect" function call
@ 2012-01-17  9:30 b.r.longbons at gmail dot com
  2012-01-17  9:53 ` [Bug c++/51878] " b.r.longbons at gmail dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: b.r.longbons at gmail dot com @ 2012-01-17  9:30 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 51878
           Summary: ICE or OOM with decltype + variadic templates +
                    "indirect" function call
    Classification: Unclassified
           Product: gcc
           Version: 4.6.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: b.r.longbons@gmail.com


Created attachment 26347
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=26347
testcase that is probably minimal

(Bugzilla is suggesting lots of duplicates for me, but they all seem to be old
...)

While trying to work around what may or may not be bug 44175, I tried not
calling the function directly. I hit compile and my computer became
unresponsive. With a little investigation, I discovered GCC was trying to
allocate an infinite amount of memory. Running gcc with niceness 19, my system
was responsive enough for me to watch 'top' until it consumed all my swap and
got OOM'ed.

Interestingly, after reducing my testcase, it allocates a lot of memory, but
eventually ICEs instead (SEGV in cc1plus). I swear I didn't change anything in
the testcase since the last time I got an OOM. Nonetheless, I've left an #error
for your safety.

Also, at least in some variants (including the original), the memory explosion
can happen after an Error. Sadly, reproducing this bug with after an error has
occurred is not possible with this minimal testcase. (The particular error was
caused by forgetting to include the pack in one of my if-branches, so it was
calling the functor with too few arguments, leading to "no match found for
apply, candidates are" and then listed the one candidate.)

Expected result:
The following code works (but is admittedly unnecessary if other GCC bugs are
fixed)

template<class F, class... T>
auto indirect_call(F f, T... t) -> decltype(f(t...))
{
    return f(t...);
}

Actual result:
If you're lucky, ICE. Else, an unresponsive system and eventually OOM.

Versions:
Here's where it gets interesting ...
* gcc <= 4.6.0 fail for various reasons unrelated to this bug.
* 4.6.1 and 4.6.2 from Gentoo, and svn branch 4.6 r183147, and whatever svn
snapshot Debian is using, have the effect described in this bug report, but
work if the call is made directly.
* svn trunk (r182728 and r183173) has some sort of regression such that even
the direct call ICEs. My gut says that should probably file a separate bug
about whatever causes that (if there isn't one already), but I don't feel I
know enough.
(My workaround for bug 44175 that works in 4.6 is also broken on trunk. I don't
know if that is the same regression that makes this one fail)


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

end of thread, other threads:[~2012-10-11 23:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-17  9:30 [Bug c++/51878] New: ICE or OOM with decltype + variadic templates + "indirect" function call b.r.longbons at gmail dot com
2012-01-17  9:53 ` [Bug c++/51878] " b.r.longbons at gmail dot com
2012-01-17 11:50 ` paolo.carlini at oracle dot com
2012-10-11 23:20 ` paolo.carlini at oracle dot com
2012-10-11 23:38 ` paolo at gcc dot gnu.org
2012-10-11 23:39 ` paolo.carlini at oracle 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).