December 29, 2001 Qualification conversions | ||||
---|---|---|---|---|
| ||||
Hi, here is another bug (DM allows me to modify const objects without explicitely casting away the "const" qualifier): #include <stdio.h> int main(int argc, char *argv[]) { const char *a = "Hello world"; char *s; const char **t = &s; // this conversion shouldn't be allowed *t = a; s[0] = ' '; char **u = &a; // this conversion shouldn't be allowed (*u)[1] = ' '; printf("%s\n", a); return 0; } The C++ standard doesn't allow these conversions (see 4.4 Qualification conversions [conv.qual]), but DM doesn't complain about it. bye, Christof -- http://cmeerw.cjb.net JID: cmeerw@jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net? |
December 29, 2001 Re: Qualification conversions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Christof Meerwald | Thanks! "Christof Meerwald" <cmeerw@web.de> wrote in message news:a0ke7d$1oac$1@digitaldaemon.com... > Hi, > > here is another bug (DM allows me to modify const objects without explicitely casting away the "const" qualifier): > > #include <stdio.h> > > int main(int argc, char *argv[]) > { > const char *a = "Hello world"; > > char *s; > const char **t = &s; // this conversion shouldn't be allowed > > *t = a; > s[0] = ' '; > > char **u = &a; // this conversion shouldn't be allowed > (*u)[1] = ' '; > > printf("%s\n", a); > > return 0; > } > > > The C++ standard doesn't allow these conversions (see 4.4 Qualification conversions [conv.qual]), but DM doesn't complain about it. > > > bye, Christof > > -- > http://cmeerw.cjb.net JID: cmeerw@jabber.at mailto cmeerw at web.de > > ...and what have you contributed to the Net? |
Copyright © 1999-2021 by the D Language Foundation