Skip to content

Commit

Permalink
fix Issue 9209 - ice(symbol.c) with const struct heap allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
WalterBright committed Apr 17, 2013
1 parent f7e81e8 commit baa93d9
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 19 deletions.
7 changes: 7 additions & 0 deletions src/optimize.c
Expand Up @@ -104,6 +104,13 @@ Expression *expandVar(int result, VarDeclaration *v)
else
goto L1;
}
else if (!(result & WANTinterpret) &&
!(v->storage_class & STCmanifest) &&
ei->isConst() != 1 && ei->op != TOKstring &&
ei->op != TOKaddress)
{
goto L1;
}
if (!ei->type)
{
goto L1;
Expand Down
38 changes: 19 additions & 19 deletions test/runnable/imports/inline2a.d
@@ -1,23 +1,23 @@
/*******************************************************************************
@file Primes.d
Copyright (C) 2004 Kris Bell
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for damages
of any kind arising from the use of this software.
Permission is hereby granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and/or
Permission is hereby granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and/or
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment within documentation of
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment within documentation of
said product would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must
2. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
3. This notice may not be removed or altered from any distribution
Expand All @@ -26,8 +26,8 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@version Initial version, April 2004
@version Initial version, April 2004
@author Kris
Expand All @@ -39,7 +39,7 @@ module imports.inline2a;
class Primes
{
private
static const short primes[] =
static const short primes[] =
[
2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
Expand Down Expand Up @@ -149,14 +149,14 @@ class Primes
*********************************************************************/

private static int bsearch (in short[] array, short match)
private static ptrdiff_t bsearch (in short[] array, short match)
{
int l, u, m;
ptrdiff_t l, u, m;

l = -1;
u = cast(int)array.length;
u = array.length;

while (l+1 != u)
while (l+1 != u)
{
m = (l + u) / 2;
if (array[m] < match)
Expand All @@ -173,7 +173,7 @@ class Primes
/**********************************************************************
return a prime number between 2 and 7919 (inclusive) that
is equal to or larger than the given 'target' number.
is equal to or larger than the given 'target' number.
**********************************************************************/

Expand Down
12 changes: 12 additions & 0 deletions test/runnable/testconst.d
Expand Up @@ -2957,6 +2957,17 @@ void test9461()

/************************************/

struct S9209 { int x; }

void bar9209(const S9209*) {}

void test9209() {
const f = new S9209(1);
bar9209(f);
}

/************************************/

int main()
{
test1();
Expand Down Expand Up @@ -3079,6 +3090,7 @@ int main()
test9046();
test9090();
test9461();
test9209();

printf("Success\n");
return 0;
Expand Down

0 comments on commit baa93d9

Please sign in to comment.