Constant Strings can't convert to int(or double) properly

These bugs do plan to be resolved, when they can be.

Moderator: GZDoom Developers

Post Reply
ZippeyKeys12
Posts: 111
Joined: Wed Jun 15, 2016 2:49 pm

Constant Strings can't convert to int(or double) properly

Post by ZippeyKeys12 »

Code: Select all

const x="12";
int y=x.ToInt();
console.printf("%d",y);
Prints 0

Code: Select all

int y="12".ToInt();
console.printf("%d",y);
Prints 0
But...

Code: Select all

String x="12";
int y=x.ToInt();
console.printf("%d",y);
Prints 12
I don't think this is intended, and while running ToInt() on a literal is pointless, some may want to run it on a constant.

EDIT: Also happens with ToDouble()
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Constant Strings can't convert to int(or double) properl

Post by Graf Zahl »

The compiler really accepts this? I am not surprised that it fails. To call a function you need to take the address of a variable. For a constant that's not possible at the moment.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49056
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Constant Strings can't convert to int(or double) properl

Post by Graf Zahl »

Moved to "on hold" because I really do not have any good idea how to deal with this.
Post Reply

Return to “On Hold Bugs”