public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/44613]  New:  Declaring an array with non-constant length inside a switch corrupts stack pointer.
@ 2010-06-21 15:42 mark dot haines at openmarket dot com
  2010-06-21 16:23 ` [Bug c++/44613] " redi at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: mark dot haines at openmarket dot com @ 2010-06-21 15:42 UTC (permalink / raw)
  To: gcc-bugs

The following program compiles with g++ -O3 without errors or warnings but sets
crash at the first printf. It seems to zero the stack pointer before calling
printf.

----- Begin switch-crash.ii
# 1 "switch-crash.cpp"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "switch-crash.cpp"
extern "C" int printf (__const char *__restrict __format, ...);

int f(int len) {
    switch(1) {
        case 1:
            char x[len];
            break;
    }
    printf("Done\n");
}

int main() {
    f(1);
    printf("Done\n");
}
------ End switch-crash.ii

Output of g++ -v:

Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.3-4ubuntu5'
--with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs
--enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared
--enable-multiarch --enable-linker-build-id --with-system-zlib
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls
--enable-clocale=gnu --enable-libstdcxx-debug --enable-plugin --enable-objc-gc
--disable-werror --with-arch-32=i486 --with-tune=generic
--enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu
--target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.3 (Ubuntu 4.4.3-4ubuntu5)


-- 
           Summary:  Declaring an array with non-constant length inside a
                    switch corrupts stack pointer.
           Product: gcc
           Version: 4.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mark dot haines at openmarket dot com
GCC target triplet: x86_64-linux-gnu


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


^ permalink raw reply	[flat|nested] 11+ messages in thread
[parent not found: <bug-44613-4@http.gcc.gnu.org/bugzilla/>]

end of thread, other threads:[~2021-08-22 22:19 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-21 15:42 [Bug c++/44613] New: Declaring an array with non-constant length inside a switch corrupts stack pointer mark dot haines at openmarket dot com
2010-06-21 16:23 ` [Bug c++/44613] " redi at gcc dot gnu dot org
2010-06-21 16:46 ` manu at gcc dot gnu dot org
2010-06-21 16:47 ` mark dot haines at openmarket dot com
2010-06-21 16:51 ` manu at gcc dot gnu dot org
2010-06-22 11:16 ` [Bug middle-end/44613] " rguenth at gcc dot gnu dot org
2010-07-21 23:45 ` [Bug c++/44613] " pinskia at gcc dot gnu dot org
     [not found] <bug-44613-4@http.gcc.gnu.org/bugzilla/>
2011-03-30  9:17 ` yselkowitz at users dot sourceforge.net
2014-04-04 19:36 ` jason at gcc dot gnu.org
2020-04-04  7:23 ` asolokha at gmx dot com
2021-08-22 22:19 ` pinskia 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).