www.digitalmars.com         C & C++   DMDScript  

D - BUG ? Conditional expression - string

reply Ant <Ant_member pathlink.com> writes:
void main()
{
  char[] s1 = false ? "yes" : "no";
  printf("s1 = >%.*s<\n",s1);

  char[] s2 = true ? "yes" : "no";
  printf("s2 = >%.*s<\n",s2);

  char[] s3 = false ? "no" : "yes";
  printf("s3 = >%.*s<\n",s3);

  char[] s4 = true ? "no" : "yes";
  printf("s4 = >%.*s<\n",s4);


}

output:

s1 = >no<
s2 = >ye<         <<<--- expected 'yes'
s3 = >yes<
s4 = >no<

oops?

Ant
Oct 09 2003
parent reply J C Calvarese <jcc7 cox.net> writes:
Ant wrote:
 void main()
 {
   char[] s1 = false ? "yes" : "no";
   printf("s1 = >%.*s<\n",s1);
 
   char[] s2 = true ? "yes" : "no";
   printf("s2 = >%.*s<\n",s2);
 
   char[] s3 = false ? "no" : "yes";
   printf("s3 = >%.*s<\n",s3);
 
   char[] s4 = true ? "no" : "yes";
   printf("s4 = >%.*s<\n",s4);
 
 
 }
 
 output:
 
 s1 = >no<
 s2 = >ye<         <<<--- expected 'yes'
 s3 = >yes<
 s4 = >no<
 
 oops?
 
 Ant
I noticed this same bug back in February: http://www.digitalmars.com/drn-bin/wwwnews?D/11108 Incidently, I think your example is a lot better than mine was. (My code word-wrapped all over the place.) Justin
Oct 10 2003
parent reply "Charles Sanders" <sanders-consulting comcast.net> writes:
This is very scary!  Whats the word on what this could be ?

C
"J C Calvarese" <jcc7 cox.net> wrote in message
news:bm7c2t$1pq9$1 digitaldaemon.com...
 Ant wrote:
 void main()
 {
   char[] s1 = false ? "yes" : "no";
   printf("s1 = >%.*s<\n",s1);

   char[] s2 = true ? "yes" : "no";
   printf("s2 = >%.*s<\n",s2);

   char[] s3 = false ? "no" : "yes";
   printf("s3 = >%.*s<\n",s3);

   char[] s4 = true ? "no" : "yes";
   printf("s4 = >%.*s<\n",s4);


 }

 output:

 s1 = >no<
 s2 = >ye<         <<<--- expected 'yes'
 s3 = >yes<
 s4 = >no<

 oops?

 Ant
I noticed this same bug back in February: http://www.digitalmars.com/drn-bin/wwwnews?D/11108 Incidently, I think your example is a lot better than mine was. (My code word-wrapped all over the place.) Justin
Oct 10 2003
parent "Walter" <walter digitalmars.com> writes:
"Charles Sanders" <sanders-consulting comcast.net> wrote in message
news:bm7c9t$1q0c$1 digitaldaemon.com...
 This is very scary!  Whats the word on what this could be ?
It's a bug, and I'm working on fixing it <g>.
Oct 13 2003