Skip to content

Usage of sizeof('\0') for computing the size of string terminators #276

@fstromback

Description

@fstromback

Hi!

I am maintaining the Debian package storm-lang (for the language Storm) that uses MPS. I just received a bug report related to code in the MPS. In particular, the bug report points out that the files code/event.h and code/eventcom.h both use sizeof('\0') to compute the size of the null-terminator in a null-terminated string. When I test this on my system, sizeof('\0') evaluates to 4, which does not look like the intended behavior. This is, however, not critical as the only effect is that "too much" memory is reserved for some buffers (if even that, due to alignment).

The bug report (linked below) proposes a fix for this issue. I am happy to submit it as a pull-request if it helps you. However, since the MPS is well-engineered I figured there might be a reason for this seemingly odd code that I have missed (either a technical one, or related to style).

The bug report is here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1058778. I have not yet tested the proposed fix, but I am happy to do so if it helps.

Metadata

Metadata

Assignees

No one assigned

    Labels

    essentialWill cause failure to meet customer requirements. Assign resources.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions