public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/55497] New: Local array (char[]) initialized with a size taken from a static variable creates an ICE
@ 2012-11-27 21:32 greg.burri at gmail dot com
  2012-11-27 21:40 ` [Bug c++/55497] " paolo.carlini at oracle dot com
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: greg.burri at gmail dot com @ 2012-11-27 21:32 UTC (permalink / raw)
  To: gcc-bugs


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

             Bug #: 55497
           Summary: Local array (char[]) initialized with a size taken
                    from a static variable creates an ICE
    Classification: Unclassified
           Product: gcc
           Version: 4.7.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: greg.burri@gmail.com


The following lines (41+42) crashes GCC 4.7.2 with an "internal compiler error:
Segmentation fault" message:

https://github.com/Ummon/D-LAN/blob/1.1.0beta13/application/Core/FileManager/priv/Cache/DataWriter.cpp#L42


If the lines are rewritten as this, it compiles without crashing (obviously):

    static const quint32 BUFFER_SIZE = 42;
    char buffer[BUFFER_SIZE];

It compiles well with GCC 4.6.2

Command line and GCC 4.7.2 message:

make[1]: Entering directory `/home/gburri/D-LAN/application/Core/FileManager'
g++ -c -pipe -std=c++0x -g -fPIC -Wall -Wno-parentheses -D_REENTRANT
-DQT_WEBKIT -DDEBUG -DFILEMANAGER_LIBRARY -DQT_NETWORK_LIB -DQT_CORE_LIB
-DQT_SHARED -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore
-I/usr/include/qt4/QtNetwork -I/usr/include/qt4 -I. -I../.. -I.tmp/debug -o
.tmp/debug/DataWriter.o priv/Cache/DataWriter.cpp
priv/Cache/DataWriter.cpp: In constructor
'FM::DataWriter::DataWriter(FM::Chunk&)':
priv/Cache/DataWriter.cpp:62:1: internal compiler error: Segmentation fault


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

* [Bug c++/55497] Local array (char[]) initialized with a size taken from a static variable creates an ICE
  2012-11-27 21:32 [Bug c++/55497] New: Local array (char[]) initialized with a size taken from a static variable creates an ICE greg.burri at gmail dot com
@ 2012-11-27 21:40 ` paolo.carlini at oracle dot com
  2012-11-27 22:28 ` greg.burri at gmail dot com
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-11-27 21:40 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2012-11-27
     Ever Confirmed|0                           |1

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-11-27 21:39:50 UTC ---
Please attach a self contained (and minimized) testcase, per the bug reporting
instructions.


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

* [Bug c++/55497] Local array (char[]) initialized with a size taken from a static variable creates an ICE
  2012-11-27 21:32 [Bug c++/55497] New: Local array (char[]) initialized with a size taken from a static variable creates an ICE greg.burri at gmail dot com
  2012-11-27 21:40 ` [Bug c++/55497] " paolo.carlini at oracle dot com
@ 2012-11-27 22:28 ` greg.burri at gmail dot com
  2012-11-27 22:28 ` greg.burri at gmail dot com
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: greg.burri at gmail dot com @ 2012-11-27 22:28 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #2 from Greg Burri <greg.burri at gmail dot com> 2012-11-27 22:27:58 UTC ---
Created attachment 28801
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28801
To segfault GCC 4.7.2 with '-g' arg


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

* [Bug c++/55497] Local array (char[]) initialized with a size taken from a static variable creates an ICE
  2012-11-27 21:32 [Bug c++/55497] New: Local array (char[]) initialized with a size taken from a static variable creates an ICE greg.burri at gmail dot com
  2012-11-27 21:40 ` [Bug c++/55497] " paolo.carlini at oracle dot com
  2012-11-27 22:28 ` greg.burri at gmail dot com
@ 2012-11-27 22:28 ` greg.burri at gmail dot com
  2012-11-27 22:31 ` greg.burri at gmail dot com
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: greg.burri at gmail dot com @ 2012-11-27 22:28 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #3 from Greg Burri <greg.burri at gmail dot com> 2012-11-27 22:28:24 UTC ---
Here we go, I attached the cpp file, just use this command line:

    g++ -g gcc_crash.cpp 

It compiles without issue if I omit the '-g' argument. It crashes on Ubuntu
12.10 and with mingw under Windows 7 both with GCC 4.7.2.

It takes me one hour to find the origin...


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

* [Bug c++/55497] Local array (char[]) initialized with a size taken from a static variable creates an ICE
  2012-11-27 21:32 [Bug c++/55497] New: Local array (char[]) initialized with a size taken from a static variable creates an ICE greg.burri at gmail dot com
                   ` (2 preceding siblings ...)
  2012-11-27 22:28 ` greg.burri at gmail dot com
@ 2012-11-27 22:31 ` greg.burri at gmail dot com
  2012-11-27 23:42 ` paolo.carlini at oracle dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: greg.burri at gmail dot com @ 2012-11-27 22:31 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #4 from Greg Burri <greg.burri at gmail dot com> 2012-11-27 22:31:05 UTC ---
Actually the template is useless, the main point is this code put in a
constructor:

    static const int v = get(1); 
    char BUFFER[v];


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

* [Bug c++/55497] Local array (char[]) initialized with a size taken from a static variable creates an ICE
  2012-11-27 21:32 [Bug c++/55497] New: Local array (char[]) initialized with a size taken from a static variable creates an ICE greg.burri at gmail dot com
                   ` (3 preceding siblings ...)
  2012-11-27 22:31 ` greg.burri at gmail dot com
@ 2012-11-27 23:42 ` paolo.carlini at oracle dot com
  2012-11-28 10:50 ` paolo at gcc dot gnu.org
  2012-11-28 10:51 ` paolo.carlini at oracle dot com
  6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-11-27 23:42 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|WAITING                     |NEW

--- Comment #5 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-11-27 23:42:14 UTC ---
Thanks a lot.

I can reproduce the issue with 4.7.2 but it's already fixed in current
4_7-branch and mainline. Thus I mean to add the testcase and close the PR.


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

* [Bug c++/55497] Local array (char[]) initialized with a size taken from a static variable creates an ICE
  2012-11-27 21:32 [Bug c++/55497] New: Local array (char[]) initialized with a size taken from a static variable creates an ICE greg.burri at gmail dot com
                   ` (4 preceding siblings ...)
  2012-11-27 23:42 ` paolo.carlini at oracle dot com
@ 2012-11-28 10:50 ` paolo at gcc dot gnu.org
  2012-11-28 10:51 ` paolo.carlini at oracle dot com
  6 siblings, 0 replies; 8+ messages in thread
From: paolo at gcc dot gnu.org @ 2012-11-28 10:50 UTC (permalink / raw)
  To: gcc-bugs


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

--- Comment #6 from paolo at gcc dot gnu.org <paolo at gcc dot gnu.org> 2012-11-28 10:49:44 UTC ---
Author: paolo
Date: Wed Nov 28 10:49:39 2012
New Revision: 193885

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=193885
Log:
2012-11-28  Paolo Carlini  <paolo.carlini@oracle.com>

    PR c++/55497
    * g++.dg/init/pr55497.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/init/pr55497.C
Modified:
    trunk/gcc/testsuite/ChangeLog


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

* [Bug c++/55497] Local array (char[]) initialized with a size taken from a static variable creates an ICE
  2012-11-27 21:32 [Bug c++/55497] New: Local array (char[]) initialized with a size taken from a static variable creates an ICE greg.burri at gmail dot com
                   ` (5 preceding siblings ...)
  2012-11-28 10:50 ` paolo at gcc dot gnu.org
@ 2012-11-28 10:51 ` paolo.carlini at oracle dot com
  6 siblings, 0 replies; 8+ messages in thread
From: paolo.carlini at oracle dot com @ 2012-11-28 10:51 UTC (permalink / raw)
  To: gcc-bugs


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
      Known to work|                            |4.7.3, 4.8.0
         Resolution|                            |FIXED
   Target Milestone|---                         |4.7.3
           Severity|major                       |normal

--- Comment #7 from Paolo Carlini <paolo.carlini at oracle dot com> 2012-11-28 10:51:02 UTC ---
Done.


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

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

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-27 21:32 [Bug c++/55497] New: Local array (char[]) initialized with a size taken from a static variable creates an ICE greg.burri at gmail dot com
2012-11-27 21:40 ` [Bug c++/55497] " paolo.carlini at oracle dot com
2012-11-27 22:28 ` greg.burri at gmail dot com
2012-11-27 22:28 ` greg.burri at gmail dot com
2012-11-27 22:31 ` greg.burri at gmail dot com
2012-11-27 23:42 ` paolo.carlini at oracle dot com
2012-11-28 10:50 ` paolo at gcc dot gnu.org
2012-11-28 10:51 ` 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).