P-p-H-d / mlib

Library of generic and type safe containers in pure C language (C99 or C11) for a wide collection of container (comparable to the C++ STL).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Possible assertion error

vladipus opened this issue · comments

image

Are you sure about that code? Shouldn't it feature _Static_assert actually, since static_assert is C++'s stuff.

this also seems a better hacky solution alternative for the second:
image

commented

Are you sure about that code? Shouldn't it feature _Static_assert actually, since static_assert is C++'s stuff.

Yes. static_assert is C11 stuff too. It is a macro which is defined in assert.h and expanded into _Static_assert

this also seems a better hacky solution alternative for the second:

This is pretty much the same solution, except msg is not a string but a token, and it tests the condition.

I actually had a problem while compiling that statis_assert was not defined, but _Static_assert worked fine. Are you sure it is defined in assert.h and that file is actually included?

commented

Yes, it is. as per C11:

The header <assert.h> defines the assert and static_assert macros

and assert.h is unconditionally included in m-core.h

Which system are you using? compiler + options ?

I can't say exactly what I've used that day, but only changing to _Static_assert has fixed the issue for me. Let me check one more time later.

Here is what I did to reproduce:

Note: My fork uses M_ prefix for array definitions. So I have removed the M_ from here in the test-marray.c
image
Now I get this error:
image
If I replace with _Static_assert the assertion is showed correctly.
I'm using this command to compile on Windows 10: C:\PROGRA~1\LLVM\bin\clang.exe -D__STDC_WANT_LIB_EXT1__=1 -D__STDC_WANT_LIB_EXT2__=1 -I../. -g -Xclang -gcodeview -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd -fmacro-backtrace-limit=0 -Wall -Wextra -Werror -Wno-unused-function -Wno-unused-macros -Wno-gnu-zero-variadic-macro-arguments -Wno-c++98-compat-pedantic -Wno-old-style-cast -Wno-zero-as-null-pointer-constant -MD -MT tests/CMakeFiles/test-marray.dir/test-marray.c.obj -MF tests\CMakeFiles\test-marray.dir\test-marray.c.obj.d -o tests/CMakeFiles/test-marray.dir/test-marray.c.obj -c ../tests/test-marray.c

commented

I was able to reproduce this behavior.
This is definitely a bug in CLANG for windows as it claims to be C11 but fails to deliver a working assert.h
I have implemented a workaround in master.