Coder Social home page Coder Social logo

Possible assertion error about mlib HOT 6 CLOSED

vladipus avatar vladipus commented on May 28, 2024
Possible assertion error

from mlib.

Comments (6)

P-p-H-d avatar P-p-H-d commented on May 28, 2024

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.

from mlib.

vladipus avatar vladipus commented on May 28, 2024

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?

from mlib.

P-p-H-d avatar P-p-H-d commented on May 28, 2024

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 ?

from mlib.

vladipus avatar vladipus commented on May 28, 2024

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.

from mlib.

vladipus avatar vladipus commented on May 28, 2024

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

from mlib.

P-p-H-d avatar P-p-H-d commented on May 28, 2024

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.

from mlib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.