Skip to content

Conversation

@khwilliamson
Copy link
Contributor

@khwilliamson khwilliamson commented Aug 14, 2025

Perl_assert_ is a long name for assert. The name __ASSERT_ is undefined behavior in C and C++.

  • This set of changes does not require a perldelta entry.

@bulk88
Copy link
Contributor

bulk88 commented Aug 15, 2025

https://github.com/search?q=%22define+__assert_%28%22&type=code 133 hits with current/old macro

https://github.com/search?q=%22define+assert_%28%22&type=code 696 hits with future proposed macro

the new preferred macro has much higher chance of a collision with 3rd party C headers

update:

Although a C compiler vendor should be calling the actual proc termination func

extern void _assert(const char * msg);

I have a suspicion this is a popular, not that brilliant choice, either in the past, or current, for C compiler authors, or random C library code bases.

extern void assert_(const char * msg);

@bulk88
Copy link
Contributor

bulk88 commented Aug 18, 2025

@mauke so as a professional developer, did you analyze which spelling of the token has the least likely hood of conflicts with 3rd party headers or not?

@tonycoz
Copy link
Contributor

tonycoz commented Aug 18, 2025

the new preferred macro has much higher chance of a collision with 3rd party C headers

The __ASSERT_() name is reserved to the implementation, which is probably why few others use it.

Although a C compiler vendor should be calling the actual proc termination func

extern void _assert(const char * msg);

_assert() is windows specific and irrelevant.

@mauke
Copy link
Contributor

mauke commented Aug 18, 2025

@mauke so as a professional developer, did you analyze which spelling of the token has the least likely hood of conflicts with 3rd party headers or not?

Yes, it's q_ac6f10cd_382f_4077_88e9_8e3e2c291ff3.

@khwilliamson
Copy link
Contributor Author

As a factoid, assert_() was added in 5.18. If its expansion conflicts with another definition, there would be a compiler warning.

This is a long name equivalent to assert_().
The former symbol is undefined behavior in C and C++.
@khwilliamson khwilliamson changed the title Convert all calls to __ASSERT_() to assert_() Add name Perl_assert_; Convert __ASSERT_() calls to assert_() Sep 3, 2025
@khwilliamson
Copy link
Contributor Author

I think it is best to not use assert_ ourselves. I found several modules on cpan that have a function with that name. Thus, I have revised the p.r. to not use it, but to use plain assert instead.

Copy link
Contributor

@tonycoz tonycoz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested with VS2017 to see if we got any macro "space overflow" errors and didn't see any.

VS2015 failed to build I think due to an incompatibility with the windows 10 SDK:

C:\Program Files (x86)\Windows Kits\10\include\10.0.26100.0\ucrt\wchar.h(316): warning C4013: '_mm_loadu_si64' undefined; assuming extern returning int
C:\Program Files (x86)\Windows Kits\10\include\10.0.26100.0\ucrt\wchar.h(316): error C2440: 'initializing': cannot convert from 'int' to '__m128i'

(I just used the normal x64 native tools command prompt shortcut)

@khwilliamson khwilliamson merged commit 4f5164a into Perl:blead Sep 4, 2025
33 checks passed
@khwilliamson khwilliamson deleted the ASSERT_ branch September 4, 2025 01:55
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.

4 participants