public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "r dot j dot hogan at reading dot ac dot uk" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/45502] New: Passing multi-dimensional array to function using C99 VLA function parameter format fails if function is inlined
Date: Thu, 02 Sep 2010 17:48:00 -0000 [thread overview]
Message-ID: <bug-45502-19646@http.gcc.gnu.org/bugzilla/> (raw)
The following code passes a multidimensional array to a function that uses the
C99 format for accepting an array when the size is not known at compile time.
The code outputs incorrect numbers (like 6.91992e-310) if the function "show"
gets inlined, which happens if I do one of these:
gcc -Wall -save-temps -std=c99 -O2 -finline-functions bug.c -o bug
gcc -Wall -save-temps -std=c99 -O3 bug.c -o bug
Using less optimization (e.g. -O1) or using the __attribute__((noinline)) on
the "show" function results in correct operation, so I presume it is the
inlining that is not working.
-------------- bug.c -------------------------------------
#include <stdio.h>
void show(int n, int m, double a[n][m]) {
int i, j;
for (i = 0; i < n; i++) {
for (j = 0; j < m; j++) {
fprintf(stderr, "a[%d][%d] = %g\n", i, j, a[i][j]);
}
}
}
int main(int argc, char** argv) {
double b[3][2] = {{1.1, 2.1}, {3.1, 4.1}, {5.1, 6.1}};
show(3,2,b);
return 0;
}
------------------------------------------------------------
>> gcc -v
Using built-in specs.
Target: x86_64-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,obj-c++,java,ada
--enable-checking=release --with-gxx-include-dir=/usr/include/c++/4.3
--enable-ssp --disable-libssp --with-bugurl=http://bugs.opensuse.org/
--with-pkgversion='SUSE Linux' --disable-libgcj --disable-libmudflap
--with-slibdir=/lib64 --with-system-zlib --enable-__cxa_atexit
--enable-libstdcxx-allocator=new --disable-libstdcxx-pch
--enable-version-specific-runtime-libs --program-suffix=-4.3
--enable-linux-futex --without-system-libunwind --with-cpu=generic
--build=x86_64-suse-linux
Thread model: posix
gcc version 4.3.2 [gcc-4_3-branch revision 141291] (SUSE Linux)
--
Summary: Passing multi-dimensional array to function using C99
VLA function parameter format fails if function is
inlined
Product: gcc
Version: 4.3.2
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: r dot j dot hogan at reading dot ac dot uk
GCC build triplet: x86_64-suse-linux
GCC host triplet: x86_64-suse-linux
GCC target triplet: x86_64-suse-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45502
next reply other threads:[~2010-09-02 17:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-02 17:48 r dot j dot hogan at reading dot ac dot uk [this message]
2010-09-02 17:56 ` [Bug c/45502] " r dot j dot hogan at reading dot ac dot uk
2010-09-02 18:35 ` paolo dot carlini at oracle dot com
2010-09-02 22:16 ` r dot j dot hogan at reading dot ac dot uk
2010-09-02 22:31 ` paolo dot carlini at oracle dot com
2010-09-02 22:34 ` r dot j dot hogan at reading dot ac dot uk
2010-09-03 9:39 ` rguenth at gcc dot gnu dot org
2010-09-03 12:55 ` rguenth at gcc dot gnu dot org
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-45502-19646@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).