Code: --- void main() { import std.regex; Regex!(char) pattern; pattern = regex(""); import vibe.core.net; void metricReceiver(TCPConnection) { } listenTCP(1, conn => metricReceiver(conn), "2"); } --- Command line (sorry haven't reduced beyond own project): --- dmd -c -inline -version=VibeUseNativeDriverType -version=VibeLibasyncDriver -I../../../.dub/packages/vibe-d-0.7.26/source/ -I../../../.dub/packages/libasync-0.7.5/source/ -I../../../.dub/packages/memutils-0.4.3/source/ --- Output: --- Using Linux EPOLL for events Error: variable __nrvoretval4587 cannot be modified at compile time /usr/include/dmd/phobos/std/regex/package.d(333): called from here: regex("^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\.|$)){4}$", "") /usr/include/dmd/phobos/std/regex/package.d(355): Error: template instance std.regex.ctRegexImpl!("^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\.|$)){4}$", "") error instantiating ../../../.dub/packages/vibe-d-0.7.26/source/vibe/core/drivers/libasync.d(197): instantiated from here: ctRegex!("^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\.|$)){4}$", "") Error: variable __nrvoretval4587 cannot be modified at compile time /usr/include/dmd/phobos/std/regex/package.d(333): called from here: regex("^([0-9A-Fa-f]{0,4}:){2,7}([0-9A-Fa-f]{1,4}$|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\.|$)){4})$", "") /usr/include/dmd/phobos/std/regex/package.d(355): Error: template instance std.regex.ctRegexImpl!("^([0-9A-Fa-f]{0,4}:){2,7}([0-9A-Fa-f]{1,4}$|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\.|$)){4})$", "") error instantiating ../../../.dub/packages/vibe-d-0.7.26/source/vibe/core/drivers/libasync.d(198): instantiated from here: ctRegex!("^([0-9A-Fa-f]{0,4}:){2,7}([0-9A-Fa-f]{1,4}$|((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\.|$)){4})$", "") --- Workaround: --- Remove -inline flag ---
Doesn't happen if I switch from 2.069 to 2.068
Reduced: main.d: ---- module main; import imp1; import imp2; void main() { regex(); listenTCP(); } ---- imp1.d: ---- module imp1; import imp2; void listenTCP() { enum r = regex(); } ---- imp2.d: ---- module imp2; int regex() { return regexImpl(); } auto regexImpl() { int r = 0; return r; } ---- `dmd -c main.d` works. `dmd -c -inline main.d` gives: ---- Error: variable __nrvoretval51 cannot be modified at compile time imp1.d(7): called from here: regex() ---- This reduction fails with 2.068 and 2.067, too. But it compiles with 2.066.
(In reply to ag0aep6g from comment #2) > Reduced: > > This reduction fails with 2.068 and 2.067, too. But it compiles with 2.066. Thanks alot! Yes, I have been seeing the error occur in 2.068 too after splitting components of the project into packages. I have an idea what was the bad commit, will give it a bisect.
First bad commit: https://github.com/D-Programming-Language/dmd/pull/4353
Commits pushed to stable at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/b56fa1d1b02c93151f0a25d868f4459cac8d6a4d fix Issue 15490 - Error variable __nrvoretval cannot be modified at compile time when using -inline CTFE interpretr can recognize a form `CommaExp(DeclaraationExp(v), VarExp(v))` as a CTFEable variable declaration when `v._init` is `null`. In other cases, for examle a sole `DeclarationExp` should have v._init for CTFE-ability. Supply `VoidInitializer` to allow inlining the temporary for NRVO. https://github.com/D-Programming-Language/dmd/commit/31232a9c64e799c439af5e3501b20cf9b7e7372b Merge pull request #5415 from 9rnsr/fix15490 [REG 2.067] Issue 15490 - Error variable __nrvoretval cannot be modified at compile time when using -inline
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/b56fa1d1b02c93151f0a25d868f4459cac8d6a4d fix Issue 15490 - Error variable __nrvoretval cannot be modified at compile time when using -inline https://github.com/D-Programming-Language/dmd/commit/31232a9c64e799c439af5e3501b20cf9b7e7372b Merge pull request #5415 from 9rnsr/fix15490