This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH, libgfortran] PR 60324 Unbounded stack allocations in libgfortran
- From: Tobias Burnus <burnus at net-b dot de>
- To: Cesar Philippidis <cesar_philippidis at mentor dot com>, Janne Blomqvist <blomqvist dot janne at gmail dot com>, Fortran List <fortran at gcc dot gnu dot org>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 14 Nov 2014 22:02:22 +0100
- Subject: Re: [PATCH, libgfortran] PR 60324 Unbounded stack allocations in libgfortran
- Authentication-results: sourceware.org; auth=none
- References: <CAO9iq9HTtPAM-ronwWCJWv7LnSbvg9sd=9oE-RqRQHEyevG7+w at mail dot gmail dot com> <54665600 dot 3080209 at mentor dot com>
Cesar Philippidis wrote:
On 11/13/2014 02:32 AM, Janne Blomqvist wrote:
I hit an error when building intrinsics/random.c:
error: expression in static assertion is not constant
Joseph told me that static const variables cannot be used in constant
expressions in C, so I've replaced the _Static_assert with a regular
assert. Are you using g++ to build libgfortran?
I wonder why you are seeing this while others aren't. It seemed to work
for me, gcc-testresults looks fine and there weren't complaints
yesterday or today. (The patch was committed 34 h ago.)
The default build should use gcc and not g++.
I don't have a good baseline test this patch thoroughly, but at least I
can bootstrap gcc without it failing in libgfortran. Is this OK for
mainline and/or could someone see if it causes any regressions?
I think instead of doing a run-time check I'd prefer something like the
following, keeping the compile-time assert.
--- a/libgfortran/intrinsics/random.c
+++ b/libgfortran/intrinsics/random.c
@@ -253 +253 @@ static GFC_UINTEGER_4 kiss_default_seed[] = {
-static const GFC_INTEGER_4 kiss_size =
sizeof(kiss_seed)/sizeof(kiss_seed[0]);
+#define KISS_SIZE ((GFC_INTEGER_4) (sizeof(kiss_seed)/sizeof(kiss_seed[0]))
(plus s/kiss_size/KISS_SIZE/ changes in the code.)
Janne, what do you think?
Tobias