public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/58080] New: internal compiler error, decltype in function declaration (for SFINAE purposes)
@ 2013-08-04 18:46 nickolay.merkin at gmail dot com
  2013-08-04 18:56 ` [Bug c++/58080] " paolo.carlini at oracle dot com
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: nickolay.merkin at gmail dot com @ 2013-08-04 18:46 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58080
           Summary: internal compiler error, decltype in function
                    declaration (for SFINAE purposes)
           Product: gcc
           Version: 4.7.3
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nickolay.merkin at gmail dot com

Created attachment 30609
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30609&action=edit
preprocessed source code that leads to the ICE

Here is minimal example that reproduces the ICE:

g++ version 4.7.3 (Ubuntu/Linaro 4.7.3-2ubuntu1~12.04)
commandline: g++ std=c++11 x.cpp
(also crashes with std=gnu++11)

// /usr/lib/gcc/i686-linux-gnu/4.7/cc1plus -quiet -imultilib . -imultiarch
i386-linux-gnu -D_GNU_SOURCE x.cpp -quiet -dumpbase x.cpp -mtune=generic
-march=i686 -auxbase x -std=c++11 -fstack-protector -o - -frandom-seed=0
# 1 "x.cpp"
# 1 "<command-line>"
# 1 "x.cpp"
template<class A, class B>
struct Eval
{
 void foo(A a, B b) { bar(a,b, 0); }
 auto bar(A a, B b, decltype(a+b)* _) -> decltype(a+b) { return a+b; }
};

int main()
{
 Eval<int,void*> eiv; eiv.foo(0,0);
}

I intended to write a multimethod that does a+b for integral, pointer, string,
etc. types, -- and immediately met ICE.
Of course, operator+(void*,int) is not defined, but it is not a reason to
crash.
The compiler prepends the crash report with three warnings about VOID* in
arithmetic expression.


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

* [Bug c++/58080] internal compiler error, decltype in function declaration (for SFINAE purposes)
  2013-08-04 18:46 [Bug c++/58080] New: internal compiler error, decltype in function declaration (for SFINAE purposes) nickolay.merkin at gmail dot com
@ 2013-08-04 18:56 ` paolo.carlini at oracle dot com
  2013-08-04 18:58 ` nickolay.merkin at gmail dot com
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-08-04 18:56 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Note that strictly speaking arithmetic on a pointer to void would be even
invalid.


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

* [Bug c++/58080] internal compiler error, decltype in function declaration (for SFINAE purposes)
  2013-08-04 18:46 [Bug c++/58080] New: internal compiler error, decltype in function declaration (for SFINAE purposes) nickolay.merkin at gmail dot com
  2013-08-04 18:56 ` [Bug c++/58080] " paolo.carlini at oracle dot com
  2013-08-04 18:58 ` nickolay.merkin at gmail dot com
@ 2013-08-04 18:58 ` paolo.carlini at oracle dot com
  2013-08-04 19:07 ` paolo.carlini at oracle dot com
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-08-04 18:58 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2013-08-04
           Assignee|unassigned at gcc dot gnu.org      |paolo.carlini at oracle dot com
   Target Milestone|---                         |4.9.0
     Ever confirmed|0                           |1
           Severity|major                       |normal


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

* [Bug c++/58080] internal compiler error, decltype in function declaration (for SFINAE purposes)
  2013-08-04 18:46 [Bug c++/58080] New: internal compiler error, decltype in function declaration (for SFINAE purposes) nickolay.merkin at gmail dot com
  2013-08-04 18:56 ` [Bug c++/58080] " paolo.carlini at oracle dot com
@ 2013-08-04 18:58 ` nickolay.merkin at gmail dot com
  2013-08-04 18:58 ` paolo.carlini at oracle dot com
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: nickolay.merkin at gmail dot com @ 2013-08-04 18:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Nickolay Merkin <nickolay.merkin at gmail dot com> ---
(In reply to Paolo Carlini from comment #1)
> Note that strictly speaking arithmetic on a pointer to void would be even
> invalid.

Yes of course, and the compiler has notified that... and then it crashed.


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

* [Bug c++/58080] internal compiler error, decltype in function declaration (for SFINAE purposes)
  2013-08-04 18:46 [Bug c++/58080] New: internal compiler error, decltype in function declaration (for SFINAE purposes) nickolay.merkin at gmail dot com
                   ` (2 preceding siblings ...)
  2013-08-04 18:58 ` paolo.carlini at oracle dot com
@ 2013-08-04 19:07 ` paolo.carlini at oracle dot com
  2013-08-04 19:26 ` nickolay.merkin at gmail dot com
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-08-04 19:07 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Paolo Carlini <paolo.carlini at oracle dot com> ---
I meant something else: I meant that on a different compiler, your code could
be hardly rejected, you should not use arithmetic on void * in the first place.


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

* [Bug c++/58080] internal compiler error, decltype in function declaration (for SFINAE purposes)
  2013-08-04 18:46 [Bug c++/58080] New: internal compiler error, decltype in function declaration (for SFINAE purposes) nickolay.merkin at gmail dot com
                   ` (3 preceding siblings ...)
  2013-08-04 19:07 ` paolo.carlini at oracle dot com
@ 2013-08-04 19:26 ` nickolay.merkin at gmail dot com
  2013-08-04 19:31 ` paolo.carlini at oracle dot com
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: nickolay.merkin at gmail dot com @ 2013-08-04 19:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Nickolay Merkin <nickolay.merkin at gmail dot com> ---
(In reply to Paolo Carlini from comment #3)
> I meant something else: I meant that on a different compiler, your code
> could be hardly rejected, you should not use arithmetic on void * in the
> first place.

I understand that.
My multimethod is intended to take 'good' combinations from 'bad', so that
int+int or int+char* are good,
char*+char* is bad,
and int+void* should be bad, too.

Say,

template<class A, class B>
auto plus_impl(A a, B b) -> decltype(a+b) { return a+b; }
int plus_impl(...) { throw bad_operands(); }

template<class A, class B>
variant_type plus(A a, B b)
{ return variant_type(plus_impl(a,b)); }

To bypass the ICE, I'd like just to add overloads of plus_impl those receive
void* as left or right operand and throw the exception as well.
But this is a bypass.

Tomorrow I'll explore how VC2010 behaves, maybe it is common problem, and the
bypass is strongly required.


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

* [Bug c++/58080] internal compiler error, decltype in function declaration (for SFINAE purposes)
  2013-08-04 18:46 [Bug c++/58080] New: internal compiler error, decltype in function declaration (for SFINAE purposes) nickolay.merkin at gmail dot com
                   ` (4 preceding siblings ...)
  2013-08-04 19:26 ` nickolay.merkin at gmail dot com
@ 2013-08-04 19:31 ` paolo.carlini at oracle dot com
  2013-08-04 20:56 ` evgeny.panasyuk at gmail dot com
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-08-04 19:31 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Current clang++, for example, simply errors out, no warning.


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

* [Bug c++/58080] internal compiler error, decltype in function declaration (for SFINAE purposes)
  2013-08-04 18:46 [Bug c++/58080] New: internal compiler error, decltype in function declaration (for SFINAE purposes) nickolay.merkin at gmail dot com
                   ` (5 preceding siblings ...)
  2013-08-04 19:31 ` paolo.carlini at oracle dot com
@ 2013-08-04 20:56 ` evgeny.panasyuk at gmail dot com
  2013-08-04 21:00 ` paolo.carlini at oracle dot com
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: evgeny.panasyuk at gmail dot com @ 2013-08-04 20:56 UTC (permalink / raw)
  To: gcc-bugs

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

Evgeny Panasyuk <evgeny.panasyuk at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |evgeny.panasyuk at gmail dot com

--- Comment #6 from Evgeny Panasyuk <evgeny.panasyuk at gmail dot com> ---
Several variations of original code shows differences in results of GCC 4.8.1
and Clang (3.4 trunk 184460):

Case 1: Both compile OK, but different overloads are selected
GCC:
http://coliru.stacked-crooked.com/view?id=58ca6a0268281fda26a36db4e5d50bbd-3ea7fded292aff0f460de2fb646b584a
Clang:
http://coliru.stacked-crooked.com/view?id=58ca6a0268281fda26a36db4e5d50bbd-80c199070668c72f0a5e12e38239d72b

Case 2: Clang compiles OK, without errors, while GCC shows "Internal compiler
error"
GCC:
http://coliru.stacked-crooked.com/view?id=7defec6f0288a8d72255a652e1baf439-3ea7fded292aff0f460de2fb646b584a
Clang:
http://coliru.stacked-crooked.com/view?id=7defec6f0288a8d72255a652e1baf439-80c199070668c72f0a5e12e38239d72b


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

* [Bug c++/58080] internal compiler error, decltype in function declaration (for SFINAE purposes)
  2013-08-04 18:46 [Bug c++/58080] New: internal compiler error, decltype in function declaration (for SFINAE purposes) nickolay.merkin at gmail dot com
                   ` (6 preceding siblings ...)
  2013-08-04 20:56 ` evgeny.panasyuk at gmail dot com
@ 2013-08-04 21:00 ` paolo.carlini at oracle dot com
  2013-08-04 21:05 ` paolo.carlini at oracle dot com
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-08-04 21:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> ---
The ICE is of course wrong, I already sent a patch for it. If there are other
issues, let's handle one at a time, in different bugs, after having checked
that mainline GCC is still affected and that there are no dups in Bugzilla.
Thanks.


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

* [Bug c++/58080] internal compiler error, decltype in function declaration (for SFINAE purposes)
  2013-08-04 18:46 [Bug c++/58080] New: internal compiler error, decltype in function declaration (for SFINAE purposes) nickolay.merkin at gmail dot com
                   ` (7 preceding siblings ...)
  2013-08-04 21:00 ` paolo.carlini at oracle dot com
@ 2013-08-04 21:05 ` paolo.carlini at oracle dot com
  2013-08-05 22:05 ` paolo.carlini at oracle dot com
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-08-04 21:05 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #8 from Paolo Carlini <paolo.carlini at oracle dot com> ---
By the way, with my patch installed, all the new testcases seem fine,
consistent with clang.


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

* [Bug c++/58080] internal compiler error, decltype in function declaration (for SFINAE purposes)
  2013-08-04 18:46 [Bug c++/58080] New: internal compiler error, decltype in function declaration (for SFINAE purposes) nickolay.merkin at gmail dot com
                   ` (8 preceding siblings ...)
  2013-08-04 21:05 ` paolo.carlini at oracle dot com
@ 2013-08-05 22:05 ` paolo.carlini at oracle dot com
  2013-08-05 22:12 ` nickolay.merkin at gmail dot com
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-08-05 22:05 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #9 from Paolo Carlini <paolo.carlini at oracle dot com> ---
Fixed for 4.9.0.


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

* [Bug c++/58080] internal compiler error, decltype in function declaration (for SFINAE purposes)
  2013-08-04 18:46 [Bug c++/58080] New: internal compiler error, decltype in function declaration (for SFINAE purposes) nickolay.merkin at gmail dot com
                   ` (9 preceding siblings ...)
  2013-08-05 22:05 ` paolo.carlini at oracle dot com
@ 2013-08-05 22:12 ` nickolay.merkin at gmail dot com
  2013-08-05 22:19 ` paolo.carlini at oracle dot com
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: nickolay.merkin at gmail dot com @ 2013-08-05 22:12 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Nickolay Merkin <nickolay.merkin at gmail dot com> ---
(In reply to Paolo Carlini from comment #9)
> Fixed for 4.9.0.
Thank you!

Will it be fixed for 4.7.3, or this version is frozen?


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

* [Bug c++/58080] internal compiler error, decltype in function declaration (for SFINAE purposes)
  2013-08-04 18:46 [Bug c++/58080] New: internal compiler error, decltype in function declaration (for SFINAE purposes) nickolay.merkin at gmail dot com
                   ` (10 preceding siblings ...)
  2013-08-05 22:12 ` nickolay.merkin at gmail dot com
@ 2013-08-05 22:19 ` paolo.carlini at oracle dot com
  2013-08-05 22:19 ` i.nixman at gmail dot com
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-08-05 22:19 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|paolo.carlini at oracle dot com    |unassigned at gcc dot gnu.org

--- Comment #11 from Paolo Carlini <paolo.carlini at oracle dot com> ---
The issue isn't about entire branches frozen, the issue is that this is an ICE
after sensible diagnostics, which moreover isn't a regression. If you feel
strongly about backports to 4.7.x and 4.8.x, just send a message to the release
managers.


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

* [Bug c++/58080] internal compiler error, decltype in function declaration (for SFINAE purposes)
  2013-08-04 18:46 [Bug c++/58080] New: internal compiler error, decltype in function declaration (for SFINAE purposes) nickolay.merkin at gmail dot com
                   ` (11 preceding siblings ...)
  2013-08-05 22:19 ` paolo.carlini at oracle dot com
@ 2013-08-05 22:19 ` i.nixman at gmail dot com
  2013-08-05 22:58 ` paolo.carlini at oracle dot com
  2013-08-06  1:09 ` i.nixman at gmail dot com
  14 siblings, 0 replies; 16+ messages in thread
From: i.nixman at gmail dot com @ 2013-08-05 22:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from niXman <i.nixman at gmail dot com> ---
(In reply to Paolo Carlini from comment #9)
> Fixed for 4.9.0.

Can you provide a commit number, please?


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

* [Bug c++/58080] internal compiler error, decltype in function declaration (for SFINAE purposes)
  2013-08-04 18:46 [Bug c++/58080] New: internal compiler error, decltype in function declaration (for SFINAE purposes) nickolay.merkin at gmail dot com
                   ` (12 preceding siblings ...)
  2013-08-05 22:19 ` i.nixman at gmail dot com
@ 2013-08-05 22:58 ` paolo.carlini at oracle dot com
  2013-08-06  1:09 ` i.nixman at gmail dot com
  14 siblings, 0 replies; 16+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-08-05 22:58 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from Paolo Carlini <paolo.carlini at oracle dot com> ---
If you need help, luckily today Jason provided a nice HOWTO here (the only
difference is that you want trunk, not 4_8-branch):
http://gcc.gnu.org/ml/gcc-bugs/2013-08/msg00320.html


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

* [Bug c++/58080] internal compiler error, decltype in function declaration (for SFINAE purposes)
  2013-08-04 18:46 [Bug c++/58080] New: internal compiler error, decltype in function declaration (for SFINAE purposes) nickolay.merkin at gmail dot com
                   ` (13 preceding siblings ...)
  2013-08-05 22:58 ` paolo.carlini at oracle dot com
@ 2013-08-06  1:09 ` i.nixman at gmail dot com
  14 siblings, 0 replies; 16+ messages in thread
From: i.nixman at gmail dot com @ 2013-08-06  1:09 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #14 from niXman <i.nixman at gmail dot com> ---
(In reply to Paolo Carlini from comment #13)

http://gcc.gnu.org/viewcvs/gcc?view=revision&sortby=date&revision=201512

thank you


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

end of thread, other threads:[~2013-08-06  1:09 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-04 18:46 [Bug c++/58080] New: internal compiler error, decltype in function declaration (for SFINAE purposes) nickolay.merkin at gmail dot com
2013-08-04 18:56 ` [Bug c++/58080] " paolo.carlini at oracle dot com
2013-08-04 18:58 ` nickolay.merkin at gmail dot com
2013-08-04 18:58 ` paolo.carlini at oracle dot com
2013-08-04 19:07 ` paolo.carlini at oracle dot com
2013-08-04 19:26 ` nickolay.merkin at gmail dot com
2013-08-04 19:31 ` paolo.carlini at oracle dot com
2013-08-04 20:56 ` evgeny.panasyuk at gmail dot com
2013-08-04 21:00 ` paolo.carlini at oracle dot com
2013-08-04 21:05 ` paolo.carlini at oracle dot com
2013-08-05 22:05 ` paolo.carlini at oracle dot com
2013-08-05 22:12 ` nickolay.merkin at gmail dot com
2013-08-05 22:19 ` paolo.carlini at oracle dot com
2013-08-05 22:19 ` i.nixman at gmail dot com
2013-08-05 22:58 ` paolo.carlini at oracle dot com
2013-08-06  1:09 ` i.nixman 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).