D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 5168 - String enums don't work with -g compiler switch
Summary: String enums don't work with -g compiler switch
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: patch
: 5985 8445 (view as issue list)
Depends on:
Blocks:
 
Reported: 2010-11-05 06:09 UTC by Marcin Kuszczak
Modified: 2013-02-05 13:31 UTC (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Marcin Kuszczak 2010-11-05 06:09:04 UTC
Test case:

File: main_1.d
---------------------------
import std.stdio;
import main_1_ext_0;

void main() {
    writeln(Names.A);
}
---------------------------

File: main_1_ext_0.d
---------------------------
module main_1_ext_0;

enum Names : string {
    A = "Beauty",
    B = "Cinderella"
}
---------------------------

dmd.exe  -g    -IC:\DMD\DMD.2.049\\src\\phobos\ -IC:\DMD\DMD.2.049 -c main_1_ext_0.d -of.objs\main_1_ext_0.obj

main_1_ext_0.d(4): Error: Integer constant expression expected instead of "Beauty"
main_1_ext_0.d(5): Error: Integer constant expression expected instead of "Cinderella"
main_1_ext_0.d(4): Error: Integer constant expression expected instead of "Beauty"
main_1_ext_0.d(5): Error: Integer constant expression expected instead of "Cinderella"
Comment 1 johannes 2011-11-15 13:27:39 UTC
still present on 2.056 (running on Win7 x64).
however, problem happens only when enum is named.
for example, the following compiles fine:

enum : string
{
  a = "a",
  b = "b"
}

int main(string[] argv)
{
  writeln(a);
  return 0;
} 



whereas the following fails:

enum X : string
{
  a = "a",  // Error: Integer constant expression expected
            //  instead of "a"
  b = "b"   // Error: Integer constant expression expected
            //  instead of "b"
}

int main(string[] argv)
{
  writeln(X.a);
  return 0;
}
Comment 2 Jesse Phillips 2011-11-16 09:04:05 UTC
*** Issue 5985 has been marked as a duplicate of this issue. ***
Comment 3 SomeDude 2012-04-22 02:16:52 UTC
Compiles and runs fine on 2.059 Win32.
Comment 4 Jesse Phillips 2012-04-23 08:29:36 UTC
(In reply to comment #3)
> Compiles and runs fine on 2.059 Win32.

I'm still getting these errors

test.d(4): Error: Integer constant expression expected instead of "a"

when compiling the named enum version with -g option.
Comment 5 SomeDude 2012-04-23 08:55:58 UTC
Indeed. I overlooked the -g option. Sorry for that.
Comment 6 Simen Kjaeraas 2012-07-26 14:16:09 UTC
*** Issue 8445 has been marked as a duplicate of this issue. ***
Comment 7 Rainer Schuetze 2012-11-27 22:31:46 UTC
https://github.com/D-Programming-Language/dmd/pull/1331
Comment 8 github-bugzilla 2012-11-29 04:20:26 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/9f068b1b07aa9b2b3da7260ff1f5ed2615c1ae89
Merge pull request #1331 from rainers/issue_5168

fix issue 5168: do not try to generate codeview debug info for non-integer enum