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

Disable all floating point functions for libc 2.1.0 on GCC12 #24

Merged
merged 1 commit into from
Jan 8, 2023

Conversation

salkinium
Copy link
Member

modm is switching to avr-gcc 12.2.0 but the compiler now generates infinite loops when calling sinf or sin. There is no warning or error emitted, so this is a very dangerous bug.

The libc 2.1.0 has proper function prototypes for the floating point functions, so we don't need to specify them here anymore.

I'm still not sure why this didn't occur with avr-gcc 11.2 or avr-gcc 10.3.

cc @ckormanyos @chris-durand

@ckormanyos
Copy link
Collaborator

ckormanyos commented Jan 8, 2023

Great catch. The recursive call surprises me also. I guess it really does make sense to simply plow ahead before digging through the myriad of defines and inline functions with varying and different <cmath> and ´<math.h>` headers.

Nice correction!

@salkinium salkinium merged commit 13363df into master Jan 8, 2023
@chris-durand
Copy link
Member

I know what happened. avr-libc 2.1.0 defines the double math functions as aliases for the float variant in math.h:

__ATTR_CONST__ extern float sinf (float __x);
__ATTR_CONST__ extern double sin (double __x) __ASM_ALIAS(sinf);        /**< The alias for sinf().  */

Thus, our duplicate definition of sinf calling sin effectively ended up calling itself recursively.

@salkinium salkinium deleted the fix/cmath_gcc_12_2 branch January 8, 2023 19:33
@chris-durand
Copy link
Member

I'm still not sure why this didn't occur with avr-gcc 11.2 or avr-gcc 10.3.

Are you sure the compiler was built against avr-libc 2.1.0? Assuming you tried this on your Mac OS machine it is likely the compilers had 2.0.0.

@salkinium
Copy link
Member Author

Ah, yes that's probably why!

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

Successfully merging this pull request may close these issues.

3 participants