Skip to content

Commit

Permalink
Merge pull request #2126 from donc/ctfe_10251pointerglobal
Browse files Browse the repository at this point in the history
10251 CTFE returning pointers to global statics of known value
  • Loading branch information
WalterBright committed Jun 5, 2013
2 parents 0ec66ad + c991a71 commit 4984910
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/interpret.c
Expand Up @@ -1547,12 +1547,6 @@ Expression *SymOffExp::interpret(InterState *istate, CtfeGoal goal)
if ( var->isDataseg() && (
(offset == 0 && isSafePointerCast(var->type, pointee)) ||
(fromType && isSafePointerCast(fromType, pointee))
) && !(vd && vd->init &&
#if DMDV2
(var->isConst() || var->isImmutable())
#else
var>isConst()
#endif
))
{
return this;
Expand Down
13 changes: 13 additions & 0 deletions test/compilable/interpret3.d
Expand Up @@ -2410,6 +2410,19 @@ bool test9745b()
}
static assert(test9745b());

/**************************************************
10251 Pointers to const globals
**************************************************/

static const int glob10251 = 7;

const (int) * bug10251()
{
return &glob10251;
}

static a10251 = &glob10251; // OK
static b10251 = bug10251();

/**************************************************
4065 [CTFE] AA "in" operator doesn't work
Expand Down

0 comments on commit 4984910

Please sign in to comment.