freebasic / fbc

FreeBASIC is a completely free, open-source, multi-platform BASIC compiler, with syntax similar to MS-QuickBASIC, that adds new features such as pointers, object orientation, unsigned data types, inline assembly, and many others.
https://www.freebasic.net
877 stars 137 forks source link

A *zstringptr can be assigned to a numeric var #111

Open countingpine opened 5 years ago

countingpine commented 5 years ago

As observed in https://freebasic.net/forum/viewtopic.php?p=254055#p254055

dim as zstring ptr  zptr = @"Hi"
dim as string  s = *zptr         '' "Hi"
dim as integer i = *zptr         '' asc("H")
print i, s, z10                  '' 72, Hi, Hi

I thought we'd fixed something like this before, but I can't find an existing bug report or changelog entry.

Potentially similar bugs were fixed at:

dkl commented 5 years ago

It could be because of string indexing; there were quite some special cases in fbc treating z/wstring pointer deref's specially because of that, treating such expressions as wchar/char integers in some places but strings in others. So for example, zstringptr[0] is treated the same as (*zstringptr)[0] in some contexts.