Menu

#98 sizeof difference with wchar_t

None
accepted
nobody
None
5
2018-02-02
2018-02-02
No

In sqratVM.h line 125 : buf[sizeof(buf) - 1] = 0;
the sizeof returns 1023 if SQChar is wchar_t :)
you could change it to:
buf[sizeof(buf)/sizeof(SQChar) - 1] = 0;

http://developer.rhino3d.com/guides/cpp/using-sizeof-with-tchar-wchar-t/

Thanks!
FluXy

Discussion

  • Wizzard

    Wizzard - 2018-02-02

    I don't think you should be using that default compiler error handler.
    It doesn't protect against large errors, which seems wrong at first glance.
    I do see that it cuts the string early for wchar_t, but it seems to have bigger problems.

    Note: sqratVM.h is a third-party "helper" included in Sqrat for convenience.
    It isn't representative of the quality of the rest of the library.

     
  • Wizzard

    Wizzard - 2018-02-02
    • status: open --> accepted
    • Group: -->
     
  • Florian Richter

    Florian Richter - 2018-02-02

    I'm actually not using it but had it on an old todo :) I think the VS static analysis reported it

    Completely forgot: scsprintf needs the size parameter with VS2015
    scsprintf(buf, 512, _SC("%s:%d:%d: %s"), source, (int) line, (int) column, desc);

     

    Last edit: Florian Richter 2018-02-03

Log in to post a comment.