www.digitalmars.com         C & C++   DMDScript  

D - static initialization bug?

reply "Kris" <someidiot earthlink.dot.dot.dot.net> writes:
I have a struct, containing a number of statically initialized instances of
another struct.

At runtime, references to these initialized instances refer to something
else entirely (name.length == 0x87762000 !). Seems like a bug, but perhaps
I'm doing something stupid?

- Kris

struct HttpStatus
{
        int             code;
        char[]          name;
}

struct HttpResponses
{
        alias static const HttpStatus httpStatus;

        httpStatus Continue                        = {100, "Continue"};
        httpStatus SwitchingProtocols              = {101,
"SwitchingProtocols"};
        httpStatus OK                              = {200, "OK"};
        httpStatus Created                         = {201, "Created"};
        httpStatus Accepted                        = {202, "Accepted"};
        httpStatus NonAuthoritativeInformation     = {203,
"NonAuthoritativeInformation"};
        httpStatus NoContent                       = {204, "NoContent"};
        httpStatus ResetContent                    = {205, "ResetContent"};
        httpStatus PartialContent                  = {206,
"PartialContent"};
        httpStatus MultipleChoices                 = {300,
"MultipleChoices"};
        httpStatus MovedPermanently                = {301,
"MovedPermanently"};
        httpStatus MovedTemporarily                = {302,
"MovedTemporarily"};
        httpStatus SeeOther                        = {303, "SeeOther"};
        httpStatus NotModified                     = {304, "NotModified"};
        httpStatus UseProxy                        = {305, "UseProxy"};
        httpStatus BadRequest                      = {400, "BadRequest"};
        httpStatus Unauthorized                    = {401, "Unauthorized"};
        httpStatus PaymentRequired                 = {402,
"PaymentRequired"};
        httpStatus Forbidden                       = {403, "Forbidden"};
        httpStatus NotFound                        = {404, "NotFound"};
        httpStatus MethodNotAllowed                = {405,
"MethodNotAllowed"};
        httpStatus NotAcceptable                   = {406, "NotAcceptable"};
        httpStatus ProxyAuthenticationRequired     = {407,
"ProxyAuthenticationRequired"};
        httpStatus RequestTimeout                  = {408,
"RequestTimeout"};
        httpStatus Conflict                        = {409, "Conflict"};
        httpStatus Gone                            = {410, "Gone"};
        httpStatus LengthRequired                  = {411,
"LengthRequired"};
        httpStatus PreconditionFailed              = {412,
"PreconditionFailed"};
        httpStatus RequestEntityTooLarge           = {413,
"RequestEntityTooLarge"};
        httpStatus RequestURITooLarge              = {414,
"RequestURITooLarge"};
        httpStatus UnsupportedMediaType            = {415,
"UnsupportedMediaType"};
        httpStatus RequestedRangeNotSatisfiable    = {416,
"RequestedRangeNotSatisfiable"};
        httpStatus ExpectationFailed               = {417,
"ExpectationFailed"};
        httpStatus InternalServerError             = {500,
"InternalServerError"};
        httpStatus NotImplemented                  = {501,
"NotImplemented"};
        httpStatus BadGateway                      = {502, "BadGateway"};
        httpStatus ServiceUnavailable              = {503,
"ServiceUnavailable"};
        httpStatus GatewayTimeout                  = {504,
"GatewayTimeout"};
        httpStatus VersionNotSupported             = {505,
"VersionNotSupported"};
}
Apr 02 2004
parent reply "Kris" <someidiot earthlink.dot.dot.dot.net> writes:
Never mind ... the FU**%#$#$* alias silently dropped the "static const" part
of its declaration. Even without this damned alias bug, it should still have
worked. So there's actually two bugs in there somewhere.


"Kris" <someidiot earthlink.dot.dot.dot.net> wrote in message
news:c4l7ug$86m$1 digitaldaemon.com...
 I have a struct, containing a number of statically initialized instances

 another struct.

 At runtime, references to these initialized instances refer to something
 else entirely (name.length == 0x87762000 !). Seems like a bug, but perhaps
 I'm doing something stupid?

 - Kris

Apr 02 2004
next sibling parent reply John Reimer <jjreimer telus.net> writes:
Kris wrote:

 Never mind ... the FU**%#$#$* alias silently dropped the "static const" part
 of its declaration. Even without this damned alias bug, it should still have
 worked. So there's actually two bugs in there somewhere.
 

Uh uh uh... Remember, Kris, "alias" is a powerful tool, and for the transcendental guru only. ;-)
Apr 02 2004
parent "Kris" <someidiot earthlink.dot.dot.dot.net> writes:
Cheers John; you are so-o-o-o-o-o right :-)

Apparently, I failed to maintain total-concentration for that fleeting
moment  ...


"John Reimer" <jjreimer telus.net> wrote in message
news:c4la79$b96$1 digitaldaemon.com...
 Kris wrote:

 Never mind ... the FU**%#$#$* alias silently dropped the "static const"


 of its declaration. Even without this damned alias bug, it should still


 worked. So there's actually two bugs in there somewhere.

Uh uh uh... Remember, Kris, "alias" is a powerful tool, and for the transcendental guru only. ;-)

Apr 02 2004
prev sibling parent reply Ben Hinkle <bhinkle4 juno.com> writes:
I'm curious, does using typedef instead of alias keep the modifiers?

On Fri, 2 Apr 2004 19:13:02 -0800, "Kris"
<someidiot earthlink.dot.dot.dot.net> wrote:

Never mind ... the FU**%#$#$* alias silently dropped the "static const" part
of its declaration. Even without this damned alias bug, it should still have
worked. So there's actually two bugs in there somewhere.


"Kris" <someidiot earthlink.dot.dot.dot.net> wrote in message
news:c4l7ug$86m$1 digitaldaemon.com...
 I have a struct, containing a number of statically initialized instances

 another struct.

 At runtime, references to these initialized instances refer to something
 else entirely (name.length == 0x87762000 !). Seems like a bug, but perhaps
 I'm doing something stupid?

 - Kris


Apr 04 2004
parent "Kris" <someidiot earthlink.dot.dot.dot.net> writes:
Afraid not Ben: I attempted that also. The only way I could get those
attributes to 'take' was to place them explicitly on each declaration.

- Kris

"Ben Hinkle" <bhinkle4 juno.com> wrote in message
news:ima170p0qa6ahr1agq9gmdg1hcm4g5k1vo 4ax.com...
 I'm curious, does using typedef instead of alias keep the modifiers?

Apr 04 2004