Skip to content

Fix strict C11 compilation of mjsan.h - #3514

Open
sylvesterkaczmarek wants to merge 1 commit into
google-deepmind:mainfrom
sylvesterkaczmarek:fix/mjsan-gcc-strict-c11
Open

Fix strict C11 compilation of mjsan.h#3514
sylvesterkaczmarek wants to merge 1 commit into
google-deepmind:mainfrom
sylvesterkaczmarek:fix/mjsan-gcc-strict-c11

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown

Summary

Make the AddressSanitizer stack instrumentation in mjsan.h compile under GCC's strict C11 mode.

The sanitizer-only definitions currently use two constructs rejected by the project's -std=c11 -Wpedantic -Werror configuration:

  • bare asm, which is not a C11 keyword
  • __attribute__((always_inline)) after the declarator on a function definition, which GCC rejects

This moves always_inline before the definition and uses __asm__ volatile for the memory barriers. The generated semantics are unchanged, and the non-sanitizer path is untouched.

This revives the still-relevant fix from closed, unmerged PR #3458 by @teerthsharma, rebased onto current main.

Validation

Focused GCC 14.2.0 compile passed:

cc -std=c11 -Wpedantic -Werror -fsanitize=address -c <minimal translation unit including mjsan.h>

Final diff: one file, six line substitutions, one commit.

A full MuJoCo sanitizer build was not run in this environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant