Bug 6779 – Error: can only initialize const member xxx inside constructor - not const, no line number

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Linux
Creation time
2011-10-07T07:34:00Z
Last change time
2012-12-30T19:27:39Z
Assigned to
nobody
Creator
steve.teale

Comments

Comment #0 by steve.teale — 2011-10-07T07:34:21Z
import mysql; // The import mysql.d contains only: /* extern (C): struct MYSQL{} MYSQL* mysql_init(MYSQL* mysql); */ // If I put this stuff in-line the error does not happen struct Connection { MYSQL _mysql; ~this() { } this(int dummy = 0) { mysql_init(&_mysql); } } // dmd -c mysqld.d // // Error: can only initialize const member _mysql inside constructor // Error: this is not mutable
Comment #1 by smjg — 2012-02-12T15:57:23Z
I'm confused. const doesn't appear anywhere in the code. And I can't reproduce the error under DMD 2.057, Win32. Can you reproduce it in any current DMD version?
Comment #2 by andrej.mitrovich — 2012-12-30T19:27:39Z
I've tried as far as DMD 2.032, can't reproduce.