public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/64049] New: Wrong code at -O3
@ 2014-11-24 13:23 bernd.edlinger at hotmail dot de
  2014-11-24 13:25 ` [Bug c++/64049] " bernd.edlinger at hotmail dot de
                   ` (13 more replies)
  0 siblings, 14 replies; 15+ messages in thread
From: bernd.edlinger at hotmail dot de @ 2014-11-24 13:23 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 64049
           Summary: Wrong code at -O3
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bernd.edlinger at hotmail dot de

the attached C++ program is mis-compiled with recent GCC trunk at -O3

g++ -O3 ValueHelper1.cpp ValueHelper2.cpp
./a.out
Assertion failed at ValueHelper1.cpp(9): Unexpected null pointer
Segmentation fault (core dumped)

which is not supposed to happen.

correct:
g++ -O2 ValueHelper1.cpp ValueHelper2.cpp
./a.out
text= Localized Text


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

* [Bug c++/64049] Wrong code at -O3
  2014-11-24 13:23 [Bug c++/64049] New: Wrong code at -O3 bernd.edlinger at hotmail dot de
@ 2014-11-24 13:25 ` bernd.edlinger at hotmail dot de
  2014-11-24 13:26 ` bernd.edlinger at hotmail dot de
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: bernd.edlinger at hotmail dot de @ 2014-11-24 13:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
Created attachment 34090
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34090&action=edit
ValueHelper1.cpp


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

* [Bug c++/64049] Wrong code at -O3
  2014-11-24 13:23 [Bug c++/64049] New: Wrong code at -O3 bernd.edlinger at hotmail dot de
  2014-11-24 13:25 ` [Bug c++/64049] " bernd.edlinger at hotmail dot de
@ 2014-11-24 13:26 ` bernd.edlinger at hotmail dot de
  2014-11-24 13:27 ` bernd.edlinger at hotmail dot de
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: bernd.edlinger at hotmail dot de @ 2014-11-24 13:26 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
Created attachment 34091
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34091&action=edit
ValueHelper2.cpp


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

* [Bug c++/64049] Wrong code at -O3
  2014-11-24 13:23 [Bug c++/64049] New: Wrong code at -O3 bernd.edlinger at hotmail dot de
  2014-11-24 13:25 ` [Bug c++/64049] " bernd.edlinger at hotmail dot de
  2014-11-24 13:26 ` bernd.edlinger at hotmail dot de
@ 2014-11-24 13:27 ` bernd.edlinger at hotmail dot de
  2014-11-24 13:41 ` pinskia at gcc dot gnu.org
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: bernd.edlinger at hotmail dot de @ 2014-11-24 13:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
Created attachment 34092
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34092&action=edit
ValueHelper.h


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

* [Bug c++/64049] Wrong code at -O3
  2014-11-24 13:23 [Bug c++/64049] New: Wrong code at -O3 bernd.edlinger at hotmail dot de
                   ` (2 preceding siblings ...)
  2014-11-24 13:27 ` bernd.edlinger at hotmail dot de
@ 2014-11-24 13:41 ` pinskia at gcc dot gnu.org
  2014-11-24 14:22 ` bernd.edlinger at hotmail dot de
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-11-24 13:41 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
 v.value.LocalizedText = (LocalizedTextStruct*) "Localized Text";


if you access v.value.LocalizedText as a LocalizedTextStruct the above causes
undefined code.


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

* [Bug c++/64049] Wrong code at -O3
  2014-11-24 13:23 [Bug c++/64049] New: Wrong code at -O3 bernd.edlinger at hotmail dot de
                   ` (3 preceding siblings ...)
  2014-11-24 13:41 ` pinskia at gcc dot gnu.org
@ 2014-11-24 14:22 ` bernd.edlinger at hotmail dot de
  2014-11-24 14:25 ` bernd.edlinger at hotmail dot de
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: bernd.edlinger at hotmail dot de @ 2014-11-24 14:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
(In reply to Andrew Pinski from comment #4)
>  v.value.LocalizedText = (LocalizedTextStruct*) "Localized Text";
> 
> 
> if you access v.value.LocalizedText as a LocalizedTextStruct the above
> causes undefined code.

I stripped that down from a much larger example.
The point is, that ValueStruct1.cpp is mis-compled,
and it cannot know what I did in ValueStruct2.cpp.

However it is easy to re-write the test case so that it does
not require any type casts.


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

* [Bug c++/64049] Wrong code at -O3
  2014-11-24 13:23 [Bug c++/64049] New: Wrong code at -O3 bernd.edlinger at hotmail dot de
                   ` (5 preceding siblings ...)
  2014-11-24 14:25 ` bernd.edlinger at hotmail dot de
@ 2014-11-24 14:25 ` bernd.edlinger at hotmail dot de
  2014-11-24 14:26 ` bernd.edlinger at hotmail dot de
                   ` (6 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: bernd.edlinger at hotmail dot de @ 2014-11-24 14:25 UTC (permalink / raw)
  To: gcc-bugs

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

Bernd Edlinger <bernd.edlinger at hotmail dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #34091|0                           |1
        is obsolete|                            |

--- Comment #7 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
Created attachment 34094
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34094&action=edit
ValueHelper2.cpp


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

* [Bug c++/64049] Wrong code at -O3
  2014-11-24 13:23 [Bug c++/64049] New: Wrong code at -O3 bernd.edlinger at hotmail dot de
                   ` (4 preceding siblings ...)
  2014-11-24 14:22 ` bernd.edlinger at hotmail dot de
@ 2014-11-24 14:25 ` bernd.edlinger at hotmail dot de
  2014-11-24 14:25 ` bernd.edlinger at hotmail dot de
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: bernd.edlinger at hotmail dot de @ 2014-11-24 14:25 UTC (permalink / raw)
  To: gcc-bugs

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

Bernd Edlinger <bernd.edlinger at hotmail dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #34090|0                           |1
        is obsolete|                            |

--- Comment #6 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
Created attachment 34093
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34093&action=edit
ValueHelper1.cpp


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

* [Bug c++/64049] Wrong code at -O3
  2014-11-24 13:23 [Bug c++/64049] New: Wrong code at -O3 bernd.edlinger at hotmail dot de
                   ` (6 preceding siblings ...)
  2014-11-24 14:25 ` bernd.edlinger at hotmail dot de
@ 2014-11-24 14:26 ` bernd.edlinger at hotmail dot de
  2014-11-24 14:31 ` bernd.edlinger at hotmail dot de
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: bernd.edlinger at hotmail dot de @ 2014-11-24 14:26 UTC (permalink / raw)
  To: gcc-bugs

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

Bernd Edlinger <bernd.edlinger at hotmail dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #34092|0                           |1
        is obsolete|                            |

--- Comment #8 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
Created attachment 34095
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34095&action=edit
ValueHelper.h


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

* [Bug c++/64049] Wrong code at -O3
  2014-11-24 13:23 [Bug c++/64049] New: Wrong code at -O3 bernd.edlinger at hotmail dot de
                   ` (7 preceding siblings ...)
  2014-11-24 14:26 ` bernd.edlinger at hotmail dot de
@ 2014-11-24 14:31 ` bernd.edlinger at hotmail dot de
  2014-11-24 16:24 ` [Bug ipa/64049] " rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: bernd.edlinger at hotmail dot de @ 2014-11-24 14:31 UTC (permalink / raw)
  To: gcc-bugs

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

Bernd Edlinger <bernd.edlinger at hotmail dot de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #34094|0                           |1
        is obsolete|                            |

--- Comment #9 from Bernd Edlinger <bernd.edlinger at hotmail dot de> ---
Created attachment 34096
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=34096&action=edit
ValueHelper2.cpp

see, no type-casts at all.


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

* [Bug ipa/64049] Wrong code at -O3
  2014-11-24 13:23 [Bug c++/64049] New: Wrong code at -O3 bernd.edlinger at hotmail dot de
                   ` (8 preceding siblings ...)
  2014-11-24 14:31 ` bernd.edlinger at hotmail dot de
@ 2014-11-24 16:24 ` rguenth at gcc dot gnu.org
  2014-11-24 17:02 ` [Bug ipa/64049] [5 Regression] r215898 caused wrong " rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-11-24 16:24 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-11-24
                 CC|                            |hubicka at gcc dot gnu.org,
                   |                            |jamborm at gcc dot gnu.org
          Component|c++                         |ipa
   Target Milestone|---                         |5.0
     Ever confirmed|0                           |1

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
-fno-devirtualize fixes it.


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

* [Bug ipa/64049] [5 Regression] r215898 caused wrong code at -O3
  2014-11-24 13:23 [Bug c++/64049] New: Wrong code at -O3 bernd.edlinger at hotmail dot de
                   ` (9 preceding siblings ...)
  2014-11-24 16:24 ` [Bug ipa/64049] " rguenth at gcc dot gnu.org
@ 2014-11-24 17:02 ` rguenth at gcc dot gnu.org
  2014-12-06  0:40 ` edlinger at gcc dot gnu.org
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2014-11-24 17:02 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P1


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

* [Bug ipa/64049] [5 Regression] r215898 caused wrong code at -O3
  2014-11-24 13:23 [Bug c++/64049] New: Wrong code at -O3 bernd.edlinger at hotmail dot de
                   ` (10 preceding siblings ...)
  2014-11-24 17:02 ` [Bug ipa/64049] [5 Regression] r215898 caused wrong " rguenth at gcc dot gnu.org
@ 2014-12-06  0:40 ` edlinger at gcc dot gnu.org
  2014-12-08 18:30 ` edlinger at gcc dot gnu.org
  2014-12-08 19:05 ` edlinger at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: edlinger at gcc dot gnu.org @ 2014-12-06  0:40 UTC (permalink / raw)
  To: gcc-bugs

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

Bernd Edlinger <edlinger at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |edlinger at gcc dot gnu.org

--- Comment #12 from Bernd Edlinger <edlinger at gcc dot gnu.org> ---
not sure if I even know what I'm doing, but this seems to fix
the test case:

Index: ipa-polymorphic-call.c
===================================================================
--- ipa-polymorphic-call.c    (revision 218433)
+++ ipa-polymorphic-call.c    (working copy)
@@ -1047,7 +1047,8 @@

   if (TREE_CODE (base_pointer) == SSA_NAME
       && SSA_NAME_IS_DEFAULT_DEF (base_pointer)
-      && TREE_CODE (SSA_NAME_VAR (base_pointer)) != PARM_DECL)
+      && TREE_CODE (SSA_NAME_VAR (base_pointer)) != PARM_DECL
+      && TREE_CODE (SSA_NAME_VAR (base_pointer)) != RESULT_DECL)
     {
       invalid = true;
       if (instance)


This line is hit exactly once, but with a RESULT_DECL instead
of a PARM_DECL. setting invalid=true makes the whole thing look so invalid
that it gets replaced by __builtin_unreachable() later on.


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

* [Bug ipa/64049] [5 Regression] r215898 caused wrong code at -O3
  2014-11-24 13:23 [Bug c++/64049] New: Wrong code at -O3 bernd.edlinger at hotmail dot de
                   ` (11 preceding siblings ...)
  2014-12-06  0:40 ` edlinger at gcc dot gnu.org
@ 2014-12-08 18:30 ` edlinger at gcc dot gnu.org
  2014-12-08 19:05 ` edlinger at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: edlinger at gcc dot gnu.org @ 2014-12-08 18:30 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from Bernd Edlinger <edlinger at gcc dot gnu.org> ---
Author: edlinger
Date: Mon Dec  8 18:30:15 2014
New Revision: 218487

URL: https://gcc.gnu.org/viewcvs?rev=218487&root=gcc&view=rev
Log:
2014-12-08  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR ipa/64049
        * ipa-polymorphic-call.c
        (pa_polymorphic_call_context::ipa_polymorphic_call): Allow RESULT_DECL.

testsuite/ChangeLog:
2014-12-08  Bernd Edlinger  <bernd.edlinger@hotmail.de>

        PR ipa/64049
        * g++.dg/ipa/pr64049.h: New.
        * g++.dg/ipa/pr64049-1.C: New.
        * g++.dg/ipa/pr64049-2.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/ipa/pr64049-1.C
    trunk/gcc/testsuite/g++.dg/ipa/pr64049-2.C
    trunk/gcc/testsuite/g++.dg/ipa/pr64049.h
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/ipa-polymorphic-call.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug ipa/64049] [5 Regression] r215898 caused wrong code at -O3
  2014-11-24 13:23 [Bug c++/64049] New: Wrong code at -O3 bernd.edlinger at hotmail dot de
                   ` (12 preceding siblings ...)
  2014-12-08 18:30 ` edlinger at gcc dot gnu.org
@ 2014-12-08 19:05 ` edlinger at gcc dot gnu.org
  13 siblings, 0 replies; 15+ messages in thread
From: edlinger at gcc dot gnu.org @ 2014-12-08 19:05 UTC (permalink / raw)
  To: gcc-bugs

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

Bernd Edlinger <edlinger at gcc dot gnu.org> changed:

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

--- Comment #14 from Bernd Edlinger <edlinger at gcc dot gnu.org> ---
Fixed on trunk, and also confirmed with the Softing OPC UA Tooklit,
where the problem was discoverd.


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

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

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-24 13:23 [Bug c++/64049] New: Wrong code at -O3 bernd.edlinger at hotmail dot de
2014-11-24 13:25 ` [Bug c++/64049] " bernd.edlinger at hotmail dot de
2014-11-24 13:26 ` bernd.edlinger at hotmail dot de
2014-11-24 13:27 ` bernd.edlinger at hotmail dot de
2014-11-24 13:41 ` pinskia at gcc dot gnu.org
2014-11-24 14:22 ` bernd.edlinger at hotmail dot de
2014-11-24 14:25 ` bernd.edlinger at hotmail dot de
2014-11-24 14:25 ` bernd.edlinger at hotmail dot de
2014-11-24 14:26 ` bernd.edlinger at hotmail dot de
2014-11-24 14:31 ` bernd.edlinger at hotmail dot de
2014-11-24 16:24 ` [Bug ipa/64049] " rguenth at gcc dot gnu.org
2014-11-24 17:02 ` [Bug ipa/64049] [5 Regression] r215898 caused wrong " rguenth at gcc dot gnu.org
2014-12-06  0:40 ` edlinger at gcc dot gnu.org
2014-12-08 18:30 ` edlinger at gcc dot gnu.org
2014-12-08 19:05 ` edlinger 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).