Bug 6497 – [safeD] Can take address of local variable through ?:

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-08-14T13:16:00Z
Last change time
2012-07-14T20:43:29Z
Keywords
accepts-invalid, pull
Assigned to
yebblies
Creator
timon.gehr

Comments

Comment #0 by timon.gehr — 2011-08-14T13:16:28Z
int* foo()@safe{ int n; int*x=&(0?n:n); return x; } This currently compiles without error. (When fixing, make sure that safe functions can still assign to a ConditionalExpression, afaik it is currently implemented by taking the address of the 2. and 3. operands.)
Comment #1 by yebblies — 2012-01-30T21:57:04Z
Comment #2 by github-bugzilla — 2012-07-14T20:12:56Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/40755eef0bbc746375aec08e7b66d4196a100c38 Issue 6497 - [safeD] Can take address of local variable through ?: If the compiler rewrote `&(a ? b : c)` to `&*(a ? &b : &c)`, re-run semantic on the `AddrExp`s to ensure they don't take addresses of local variables. Fixes issue 6497 https://github.com/D-Programming-Language/dmd/commit/fe4ea16128943196247b28e0ccc804c69e52d255 Merge pull request #664 from yebblies/issue6497 Issue 6497 - [safeD] Can take address of local variable through ?: