cancel
Showing results for 
Search instead for 
Did you mean: 

isalnum() seems returning wrong result (Nucleo-G431RB + cubeIDE 1.5.1)

BVauc.1
Associate II

I was expected that isalnum(c) return TRUE when c is '0' to '9' or 'A' to 'Z' or 'a' to 'z' and returns FALSE with any other value. Is it correct?

I observed it returns true for any printable character, including '\r', '*', ...

The code below was used to test:

for (int i=0;i<256;i++){

         printf ("ascii car %d isalnum? ",i);

          if (isalnum((char)i)) printf ("yes\n");

          else printf (" no\n");

  }*/

The output was:

ascii car 0 isalnum? no

ascii car 1 isalnum? no

ascii car 2 isalnum? no

ascii car 3 isalnum? no

ascii car 4 isalnum? no

ascii car 5 isalnum? no

ascii car 6 isalnum? no

ascii car 7 isalnum? no

ascii car 8 isalnum? no

ascii car 9 isalnum? yes

ascii car 10 isalnum? yes

ascii car 11 isalnum? yes

ascii car 12 isalnum? yes

ascii car 13 isalnum? yes

ascii car 14 isalnum? no

ascii car 15 isalnum? no

ascii car 16 isalnum? no

ascii car 17 isalnum? no

ascii car 18 isalnum? no

ascii car 19 isalnum? no

ascii car 20 isalnum? no

ascii car 21 isalnum? no

ascii car 22 isalnum? no

ascii car 23 isalnum? no

ascii car 24 isalnum? no

ascii car 25 isalnum? no

ascii car 26 isalnum? no

ascii car 27 isalnum? no

ascii car 28 isalnum? no

ascii car 29 isalnum? no

ascii car 30 isalnum? no

ascii car 31 isalnum? no

ascii car 32 isalnum? yes

ascii car 33 isalnum? yes

ascii car 34 isalnum? yes

ascii car 35 isalnum? yes

ascii car 36 isalnum? yes

ascii car 37 isalnum? yes

ascii car 38 isalnum? yes

ascii car 39 isalnum? yes

ascii car 40 isalnum? yes

ascii car 41 isalnum? yes

ascii car 42 isalnum? yes

ascii car 43 isalnum? yes

ascii car 44 isalnum? yes

ascii car 45 isalnum? yes

ascii car 46 isalnum? yes

ascii car 47 isalnum? yes

ascii car 48 isalnum? yes

ascii car 49 isalnum? yes

ascii car 50 isalnum? yes

ascii car 51 isalnum? yes

ascii car 52 isalnum? yes

ascii car 53 isalnum? yes

ascii car 54 isalnum? yes

ascii car 55 isalnum? yes

ascii car 56 isalnum? yes

ascii car 57 isalnum? yes

ascii car 58 isalnum? yes

ascii car 59 isalnum? yes

ascii car 60 isalnum? yes

ascii car 61 isalnum? yes

ascii car 62 isalnum? yes

ascii car 63 isalnum? yes

ascii car 64 isalnum? yes

ascii car 65 isalnum? yes

ascii car 66 isalnum? yes

ascii car 67 isalnum? yes

ascii car 68 isalnum? yes

ascii car 69 isalnum? yes

ascii car 70 isalnum? yes

ascii car 71 isalnum? yes

ascii car 72 isalnum? yes

ascii car 73 isalnum? yes

ascii car 74 isalnum? yes

ascii car 75 isalnum? yes

ascii car 76 isalnum? yes

ascii car 77 isalnum? yes

ascii car 78 isalnum? yes

ascii car 79 isalnum? yes

ascii car 80 isalnum? yes

ascii car 81 isalnum? yes

ascii car 82 isalnum? yes

ascii car 83 isalnum? yes

ascii car 84 isalnum? yes

ascii car 85 isalnum? yes

ascii car 86 isalnum? yes

ascii car 87 isalnum? yes

ascii car 88 isalnum? yes

ascii car 89 isalnum? yes

ascii car 90 isalnum? yes

ascii car 91 isalnum? yes

ascii car 92 isalnum? yes

ascii car 93 isalnum? yes

ascii car 94 isalnum? yes

ascii car 95 isalnum? yes

ascii car 96 isalnum? yes

ascii car 97 isalnum? yes

ascii car 98 isalnum? yes

ascii car 99 isalnum? yes

ascii car 100 isalnum? yes

ascii car 101 isalnum? yes

ascii car 102 isalnum? yes

ascii car 103 isalnum? yes

ascii car 104 isalnum? yes

ascii car 105 isalnum? yes

ascii car 106 isalnum? yes

ascii car 107 isalnum? yes

ascii car 108 isalnum? yes

ascii car 109 isalnum? yes

ascii car 110 isalnum? yes

ascii car 111 isalnum? yes

ascii car 112 isalnum? yes

ascii car 113 isalnum? yes

ascii car 114 isalnum? yes

ascii car 115 isalnum? yes

ascii car 116 isalnum? yes

ascii car 117 isalnum? yes

ascii car 118 isalnum? yes

ascii car 119 isalnum? yes

ascii car 120 isalnum? yes

ascii car 121 isalnum? yes

ascii car 122 isalnum? yes

ascii car 123 isalnum? yes

ascii car 124 isalnum? yes

ascii car 125 isalnum? yes

ascii car 126 isalnum? yes

ascii car 127 isalnum? no

ascii car 128 isalnum? no

ascii car 129 isalnum? no

ascii car 130 isalnum? no

ascii car 131 isalnum? no

ascii car 132 isalnum? no

ascii car 133 isalnum? no

ascii car 134 isalnum? no

ascii car 135 isalnum? no

ascii car 136 isalnum? no

ascii car 137 isalnum? no

ascii car 138 isalnum? no

ascii car 139 isalnum? no

ascii car 140 isalnum? no

ascii car 141 isalnum? no

ascii car 142 isalnum? no

ascii car 143 isalnum? no

ascii car 144 isalnum? no

ascii car 145 isalnum? no

ascii car 146 isalnum? no

ascii car 147 isalnum? no

ascii car 148 isalnum? no

ascii car 149 isalnum? no

ascii car 150 isalnum? no

ascii car 151 isalnum? no

ascii car 152 isalnum? no

ascii car 153 isalnum? no

ascii car 154 isalnum? no

ascii car 155 isalnum? no

ascii car 156 isalnum? no

ascii car 157 isalnum? no

ascii car 158 isalnum? no

ascii car 159 isalnum? no

ascii car 160 isalnum? no

ascii car 161 isalnum? no

ascii car 162 isalnum? no

ascii car 163 isalnum? no

ascii car 164 isalnum? no

ascii car 165 isalnum? no

ascii car 166 isalnum? no

ascii car 167 isalnum? no

ascii car 168 isalnum? no

ascii car 169 isalnum? no

ascii car 170 isalnum? no

ascii car 171 isalnum? no

ascii car 172 isalnum? no

ascii car 173 isalnum? no

ascii car 174 isalnum? no

ascii car 175 isalnum? no

ascii car 176 isalnum? no

ascii car 177 isalnum? no

ascii car 178 isalnum? no

ascii car 179 isalnum? no

ascii car 180 isalnum? no

ascii car 181 isalnum? no

ascii car 182 isalnum? no

ascii car 183 isalnum? no

ascii car 184 isalnum? no

ascii car 185 isalnum? no

ascii car 186 isalnum? no

ascii car 187 isalnum? no

ascii car 188 isalnum? no

ascii car 189 isalnum? no

ascii car 190 isalnum? no

ascii car 191 isalnum? no

ascii car 192 isalnum? no

ascii car 193 isalnum? no

ascii car 194 isalnum? no

ascii car 195 isalnum? no

ascii car 196 isalnum? no

ascii car 197 isalnum? no

ascii car 198 isalnum? no

ascii car 199 isalnum? no

ascii car 200 isalnum? no

ascii car 201 isalnum? no

ascii car 202 isalnum? no

ascii car 203 isalnum? no

ascii car 204 isalnum? no

ascii car 205 isalnum? no

ascii car 206 isalnum? no

ascii car 207 isalnum? no

ascii car 208 isalnum? no

ascii car 209 isalnum? no

ascii car 210 isalnum? no

ascii car 211 isalnum? no

ascii car 212 isalnum? no

ascii car 213 isalnum? no

ascii car 214 isalnum? no

ascii car 215 isalnum? no

ascii car 216 isalnum? no

ascii car 217 isalnum? no

ascii car 218 isalnum? no

ascii car 219 isalnum? no

ascii car 220 isalnum? no

ascii car 221 isalnum? no

ascii car 222 isalnum? no

ascii car 223 isalnum? no

ascii car 224 isalnum? no

ascii car 225 isalnum? no

ascii car 226 isalnum? no

ascii car 227 isalnum? no

ascii car 228 isalnum? no

ascii car 229 isalnum? no

ascii car 230 isalnum? no

ascii car 231 isalnum? no

ascii car 232 isalnum? no

ascii car 233 isalnum? no

ascii car 234 isalnum? no

ascii car 235 isalnum? no

ascii car 236 isalnum? no

ascii car 237 isalnum? no

ascii car 238 isalnum? no

ascii car 239 isalnum? no

ascii car 240 isalnum? no

ascii car 241 isalnum? no

ascii car 242 isalnum? no

ascii car 243 isalnum? no

ascii car 244 isalnum? no

ascii car 245 isalnum? no

ascii car 246 isalnum? no

ascii car 247 isalnum? no

ascii car 248 isalnum? no

ascii car 249 isalnum? no

ascii car 250 isalnum? no

ascii car 251 isalnum? no

ascii car 252 isalnum? no

ascii car 253 isalnum? no

ascii car 254 isalnum? no

ascii car 255 isalnum? no

tested on STM32CubeIDE Version: 1.5.1

Build: 9029_20201210_1234 (UTC)

1 ACCEPTED SOLUTION

Accepted Solutions
BVauc.1
Associate II

If I remove the line #include            <ctype.h> it works correctly. I think the subject is solved, but il makes me anxious about the reliability of my code

View solution in original post

5 REPLIES 5
BVauc.1
Associate II

After searching again on the same subject, the ctype.h header seems not synchronized with it's compiled library.

the header path is D:\ST\STM32CubeIDE_1.0.2\STM32CubeIDE\plugins\com.st.stm32cube.ide.mcu.externaltools.gnu-tools-for-stm32.7-2018-q2-update.win32_1.5.0.202011040924\tools\arm-none-eabi\include

Markus GIRDLAND
ST Employee

Hello BVauc!

Does this mean that you are currently getting the correct output from isalnum? If so, what did you do? I can’t see anything In the header file that doesn’t match our precompiled versions.

Could you check what pointer __locale_ctype_ptr() returns and then check with the memory view?

It should either return a faulty address or the area where it points is corrupt. That should give an idea of what the problem is.

0693W000006HWiXQAW.jpg

BVauc.1
Associate II

Hello Markus, thanks for your analyze, you are probably right, the memory contains anything but the patern you show.

BVauc.1
Associate II

0693W000006HlKuQAK.png0693W000006HlJIQA0.png

BVauc.1
Associate II

If I remove the line #include            <ctype.h> it works correctly. I think the subject is solved, but il makes me anxious about the reliability of my code