Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C99 fixed-width integer and floating-point types #8

Closed
michael-schwarz opened this issue Nov 6, 2019 · 4 comments
Closed

C99 fixed-width integer and floating-point types #8

michael-schwarz opened this issue Nov 6, 2019 · 4 comments
Milestone

Comments

@michael-schwarz
Copy link
Member

When running tests such as testrun/math1 on a machine with a newer version of glibc, we produce a parse error, that seems to be related to the headers using the float128 type.

We encountered this not just with toy programs, but also with real-world examples.

Find some way of still being able to parse these headers, probably by introducing a new typ for float128. On the Goblint side of things, we can just treat it (almost) like normal floats as we don't do anything for them anyway.

Related links:

@michael-schwarz michael-schwarz changed the title Do not fail when including newer versions of math.h Support newer versions of math.h Nov 6, 2019
@vogler vogler mentioned this issue Nov 6, 2019
22 tasks
vogler added a commit that referenced this issue Nov 6, 2019
@vogler
Copy link
Collaborator

vogler commented Nov 6, 2019

That should be enough to parse those things, but I wonder whether we need all of them in typeSpecifier.
What's the difference between __int64 and int64_t or __float128 and Float128? The former are probably only extensions, while the latter were added in C99, see https://en.wikipedia.org/wiki/C_data_types#Fixed-width_integer_types. Should add all those to the lexer/parser as well, I guess.
Also float_t/double_t:

The C99 standard includes new real floating-point types float_t and double_t, defined in <math.h>. They correspond to the types used for the intermediate results of floating-point expressions when FLT_EVAL_METHOD is 0, 1, or 2. These types may be wider than long double.

At least those fixed width types are unambiguous. What we do for the more common int, long, float, double is another problem. We just assume they have the size of the machine CIL was built on, which might not be the case for the environment the analyzed program will run in.

_build/machdep.ml:

let gcc = {
(* Generated by code in src/machdep-ml.c *)
	 version_major    = 9;
	 version_minor    = 2;
	 version          = "9.2.0";
	 sizeof_short          = 2;
	 sizeof_int            = 4;
	 sizeof_bool           = 1;
	 sizeof_long           = 8;
	 sizeof_longlong       = 8;
	 sizeof_ptr            = 8;
	 sizeof_float          = 4;
	 sizeof_double         = 8;
	 sizeof_longdouble     = 16;
	 sizeof_void           = 1;
	 sizeof_fun            = 1;
	 size_t                = "unsigned long";
	 wchar_t               = "int";
	 alignof_short         = 2;
	 alignof_int           = 4;
	 alignof_bool          = 1;
	 alignof_long          = 8;
	 alignof_longlong      = 8;
	 alignof_ptr           = 8;
	 alignof_enum          = 4;
	 alignof_float         = 4;
	 alignof_double        = 8;
	 alignof_longdouble    = 16;
	 alignof_str           = 1;
	 alignof_fun           = 1;
	 alignof_aligned       = 16;
	 char_is_unsigned      = false;
	 const_string_literals = true;
	 underscore_name       = true;
	 __builtin_va_list     = true;
	 __thread_is_keyword   = true;
	 little_endian         = true;
}

So on my machine long double == __float128 == Float128.

@vogler vogler changed the title Support newer versions of math.h C99 fixed-width integer and floating-point types, complex numbers Nov 6, 2019
@vogler
Copy link
Collaborator

vogler commented Nov 6, 2019

Ok, those int64_t etc. are defined in <inttypes.h>, so they don't need to be added.
However, for floats there's apparently no such header and the types from here should be added. TODO how many? N=8,16,32,64,128?
https://gcc.gnu.org/onlinedocs/gcc/Floating-Types.html
https://stackoverflow.com/questions/2524737/fixed-size-floating-point-types

@michael-schwarz
Copy link
Member Author

I added _Float128 for now, so I can use the math1 example to see which other changes are required.

Right now, we get Error: Invalid combination of type specifiers.

michael-schwarz added a commit that referenced this issue Jan 14, 2020
michael-schwarz added a commit that referenced this issue Jan 14, 2020
and make connection with cabs
References #8, References #9
michael-schwarz added a commit that referenced this issue Jan 15, 2020
Requires running ./configure after pulling if it is not a fresh checkout

Should mean complex and tgmath work now, more tests needed though. References #8, References #9
michael-schwarz added a commit that referenced this issue Jan 16, 2020
iF can also be written Fi
i is the same as Di
References #8, References #9
michael-schwarz added a commit that referenced this issue Jan 16, 2020
iF can also be written Fi
i is the same as Di
References #8, References #9
@michael-schwarz michael-schwarz changed the title C99 fixed-width integer and floating-point types, complex numbers C99 fixed-width integer and floating-point types Jan 16, 2020
michael-schwarz added a commit that referenced this issue Jan 23, 2020
C99: Support for Complex Floats and tgmath.h.
Closes #6 , References #8, References #9
@sim642 sim642 mentioned this issue Dec 15, 2021
3 tasks
@michael-schwarz
Copy link
Member Author

With #10, #60, #68, and #49 everything here seems to be covered.

The fixed-width integer types seem to be just type-defed to more usual types in GCC as evidenced by 9e3b8c6 (at least for Linux).

I'll wait and see what OS X CI says, but otherwise I think we can close this issue.

@sim642 sim642 added this to the 2.0.0 milestone Aug 12, 2022
sim642 added a commit to sim642/opam-repository that referenced this issue Aug 12, 2022
CHANGES:

* Wrap library into `GoblintCil` module (goblint/cil#107).
* Remove all MSVC support (goblint/cil#52, goblint/cil#88).
* Port entire build process from configure/make to dune (goblint/cil#104).
* Add C11 `_Generic` support (goblint/cil#48).
* Add C11 `_Noreturn` support (goblint/cil#58).
* Add C11 `_Static_assert` support (goblint/cil#62).
* Add C11 `_Alignof` support (goblint/cil#66).
* Add C11 `_Alignas` support (goblint/cil#93, goblint/cil#108).
* Add partial C11 `_Atomic` support (goblint/cil#61).
* Add `_Float32`, `_Float64`, `_Float32x` and `_Float64x` type support (goblint/cil#8, goblint/cil#60).
* Add Universal Character Names, `char16_t` and `char32_t` type support (goblint/cil#80).
* Change locations to location spans and add additional expression locations (goblint/cil#51).
* Add synthetic marking for CIL-inserted statement locations (goblint/cil#98).
* Expose list of files from line control directives (goblint/cil#73).
* Add parsed location transformation hook (goblint/cil#89).
* Use Zarith for integer constants (goblint/cil#47, goblint/cil#53).
* Fix constant folding overflows (goblint/cil#59).
* Add option to disable constant branch removal (goblint/cil#103).
* Add standalone expression parsing and checking (goblint/cil#97, goblint/cil#96).
* Improve inline function merging (goblint/cil#72, goblint/cil#85, goblint/cil#84, goblint/cil#86).
* Fix some attribute parsing cases (goblint/cil#71, goblint/cil#75, goblint/cil#76, goblint/cil#77).
* Fix global NaN initializers (goblint/cil#78, goblint/cil#79).
* Fix `cilly` binary installation (goblint/cil#99, goblint/cil#100, goblint/cil#102).
* Remove batteries dependency to support OCaml 5 (goblint/cil#106).
sim642 added a commit to sim642/opam-repository that referenced this issue Aug 12, 2022
CHANGES:

* Wrap library into `GoblintCil` module (goblint/cil#107).
* Remove all MSVC support (goblint/cil#52, goblint/cil#88).
* Port entire build process from configure/make to dune (goblint/cil#104).
* Add C11 `_Generic` support (goblint/cil#48).
* Add C11 `_Noreturn` support (goblint/cil#58).
* Add C11 `_Static_assert` support (goblint/cil#62).
* Add C11 `_Alignof` support (goblint/cil#66).
* Add C11 `_Alignas` support (goblint/cil#93, goblint/cil#108).
* Add partial C11 `_Atomic` support (goblint/cil#61).
* Add `_Float32`, `_Float64`, `_Float32x` and `_Float64x` type support (goblint/cil#8, goblint/cil#60).
* Add Universal Character Names, `char16_t` and `char32_t` type support (goblint/cil#80).
* Change locations to location spans and add additional expression locations (goblint/cil#51).
* Add synthetic marking for CIL-inserted statement locations (goblint/cil#98).
* Expose list of files from line control directives (goblint/cil#73).
* Add parsed location transformation hook (goblint/cil#89).
* Use Zarith for integer constants (goblint/cil#47, goblint/cil#53).
* Fix constant folding overflows (goblint/cil#59).
* Add option to disable constant branch removal (goblint/cil#103).
* Add standalone expression parsing and checking (goblint/cil#97, goblint/cil#96).
* Improve inline function merging (goblint/cil#72, goblint/cil#85, goblint/cil#84, goblint/cil#86).
* Fix some attribute parsing cases (goblint/cil#71, goblint/cil#75, goblint/cil#76, goblint/cil#77).
* Fix global NaN initializers (goblint/cil#78, goblint/cil#79).
* Fix `cilly` binary installation (goblint/cil#99, goblint/cil#100, goblint/cil#102).
* Remove batteries dependency to support OCaml 5 (goblint/cil#106).
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

No branches or pull requests

3 participants