## digitalmars.D - Weird bug

• kinghajj (35/35) Nov 02 2004 I've written a rot13 conversion function.
• Regan Heath (8/44) Nov 02 2004 No, but I have another clue, changin it to:
• kinghajj (2/51) Nov 02 2004
• Derek Parnell (6/64) Nov 02 2004 Changing 'char' to 'int' also causes your original code to work.
• kinghajj (15/20) Nov 02 2004 OK, I cleaned-up my code:
• Walter (1/1) Nov 03 2004 It's definitely a compiler bug.
• Walter (1/1) Nov 03 2004 And I have it fixed now. Thanks!
• kinghajj (3/4) Nov 03 2004 Cool, and thanks!
• Walter (4/11) Nov 03 2004 You can workaround for the time being by making it an int parameter, or
```I've written a rot13 conversion function.

/*
Produces the rot13 of one letter.
*/
char rot13_c(char ret)
{
if(ret > 'A'-1 && ret < 'N')
{ret += 13;}
else if(ret > 'M' && ret < 'Z'+1)
{ret -= 13;}
else if(ret > 'a'-1 && ret < 'n')
{ret += 13;}
else if(ret > 'm' && ret < 'z'+1)
{ret -= 13;}

return ret;
}

For some reason, it doesn't work unless I add a "printf()" statement between the
final "else if" clause and the return.

/*
Produces the rot13 of one letter.
*/
char rot13_c(char ret)
{
if(ret > 'A'-1 && ret < 'N')
{ret += 13;}
else if(ret > 'M' && ret < 'Z'+1)
{ret -= 13;}
else if(ret > 'a'-1 && ret < 'n')
{ret += 13;}
else if(ret > 'm' && ret < 'z'+1)
{ret -= 13;}
printf("");
return ret;
}

Can anyone explain why this is happening??
```
Nov 02 2004
Regan Heath <regan netwin.co.nz> writes:
```On Wed, 3 Nov 2004 00:25:34 +0000 (UTC), kinghajj
I've written a rot13 conversion function.

/*
Produces the rot13 of one letter.
*/
char rot13_c(char ret)
{
if(ret > 'A'-1 && ret < 'N')
{ret += 13;}
else if(ret > 'M' && ret < 'Z'+1)
{ret -= 13;}
else if(ret > 'a'-1 && ret < 'n')
{ret += 13;}
else if(ret > 'm' && ret < 'z'+1)
{ret -= 13;}

return ret;
}

For some reason, it doesn't work unless I add a "printf()" statement
between the
final "else if" clause and the return.

/*
Produces the rot13 of one letter.
*/
char rot13_c(char ret)
{
if(ret > 'A'-1 && ret < 'N')
{ret += 13;}
else if(ret > 'M' && ret < 'Z'+1)
{ret -= 13;}
else if(ret > 'a'-1 && ret < 'n')
{ret += 13;}
else if(ret > 'm' && ret < 'z'+1)
{ret -= 13;}
printf("");
return ret;
}

Can anyone explain why this is happening??

No, but I have another clue, changin it to:

char rot13_c(inout char ret)

causes it to start working also.

Regan

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
```
Nov 02 2004
```huh... that's strange. But, it works for me to.

In article <opsgu5capg5a2sq9 digitalmars.com>, Regan Heath says...
On Wed, 3 Nov 2004 00:25:34 +0000 (UTC), kinghajj
I've written a rot13 conversion function.

/*
Produces the rot13 of one letter.
*/
char rot13_c(char ret)
{
if(ret > 'A'-1 && ret < 'N')
{ret += 13;}
else if(ret > 'M' && ret < 'Z'+1)
{ret -= 13;}
else if(ret > 'a'-1 && ret < 'n')
{ret += 13;}
else if(ret > 'm' && ret < 'z'+1)
{ret -= 13;}

return ret;
}

For some reason, it doesn't work unless I add a "printf()" statement
between the
final "else if" clause and the return.

/*
Produces the rot13 of one letter.
*/
char rot13_c(char ret)
{
if(ret > 'A'-1 && ret < 'N')
{ret += 13;}
else if(ret > 'M' && ret < 'Z'+1)
{ret -= 13;}
else if(ret > 'a'-1 && ret < 'n')
{ret += 13;}
else if(ret > 'm' && ret < 'z'+1)
{ret -= 13;}
printf("");
return ret;
}

Can anyone explain why this is happening??

No, but I have another clue, changin it to:

char rot13_c(inout char ret)

causes it to start working also.

Regan

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

```
Nov 02 2004
Derek Parnell <derek psych.ward> writes:
```On Wed, 3 Nov 2004 03:05:43 +0000 (UTC), kinghajj wrote:

huh... that's strange. But, it works for me to.

In article <opsgu5capg5a2sq9 digitalmars.com>, Regan Heath says...
On Wed, 3 Nov 2004 00:25:34 +0000 (UTC), kinghajj
I've written a rot13 conversion function.

/*
Produces the rot13 of one letter.
*/
char rot13_c(char ret)
{
if(ret > 'A'-1 && ret < 'N')
{ret += 13;}
else if(ret > 'M' && ret < 'Z'+1)
{ret -= 13;}
else if(ret > 'a'-1 && ret < 'n')
{ret += 13;}
else if(ret > 'm' && ret < 'z'+1)
{ret -= 13;}

return ret;
}

For some reason, it doesn't work unless I add a "printf()" statement
between the
final "else if" clause and the return.

/*
Produces the rot13 of one letter.
*/
char rot13_c(char ret)
{
if(ret > 'A'-1 && ret < 'N')
{ret += 13;}
else if(ret > 'M' && ret < 'Z'+1)
{ret -= 13;}
else if(ret > 'a'-1 && ret < 'n')
{ret += 13;}
else if(ret > 'm' && ret < 'z'+1)
{ret -= 13;}
printf("");
return ret;
}

Can anyone explain why this is happening??

No, but I have another clue, changin it to:

char rot13_c(inout char ret)

causes it to start working also.

Regan

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

Changing 'char' to 'int' also causes your original code to work.

--
Derek
Melbourne, Australia
3/11/2004 3:43:05 PM
```
Nov 02 2004
```In article <cm9nll\$1bao\$1 digitaldaemon.com>, Derek Parnell says...
Changing 'char' to 'int' also causes your original code to work.

--
Derek
Melbourne, Australia
3/11/2004 3:43:05 PM

OK, I cleaned-up my code:

char rot13_c(int ret)
{
if(ret >= 'A' && ret <= 'M')
ret += 13;
else if(ret >= 'N' && ret <= 'Z')
ret -= 13;
else if(ret >= 'a' && ret <= 'm')
ret += 13;
else if(ret >= 'n' && ret <= 'z')
ret -= 13;

return ret;
}

still, I don't see why 'ret' needs to be int, but it works just fine.
```
Nov 02 2004
"Walter" <newshound digitalmars.com> writes:
```It's definitely a compiler bug.
```
Nov 03 2004
"Walter" <newshound digitalmars.com> writes:
```And I have it fixed now. Thanks!
```
Nov 03 2004
```In article <cmbbk8\$7q8\$1 digitaldaemon.com>, Walter says...
And I have it fixed now. Thanks!

Cool, and thanks!
I guess I'll have to wait for v. 0.106
```
Nov 03 2004
"Walter" <newshound digitalmars.com> writes:
```"kinghajj" <kinghajj_member pathlink.com> wrote in message
news:cmc012\$1c7v\$1 digitaldaemon.com...
In article <cmbbk8\$7q8\$1 digitaldaemon.com>, Walter says...
And I have it fixed now. Thanks!

Cool, and thanks!
I guess I'll have to wait for v. 0.106

You can workaround for the time being by making it an int parameter, or
inserting a call to printf("");
```
Nov 03 2004