← All stories
● Covered by 1 source · 1 reportMedium impact

GCC and Clang Fail to Comply with C++ Standard on Function Linkage

Aggregated by BrevFeed dev · updated 19h ago
🔖 Save

GCC and Clang do not support the C++ standard's requirement for distinct language linkages for function types, allowing C and C++ function types to be treated as identical. This issue can lead to compilation problems and violates the one definition rule in C++. The standard may need to be updated to clarify language linkage implementation requirements.

Key points

Introduction

C++ defines various language linkages associated with function types, which can be 'C++', 'C', or implementation-defined. According to the standard, function types with different language linkages must be considered distinct for compatibility reasons.

GCC and Clang's Non-compliance

Both GCC and Clang do not implement the requirement to store language linkage information with function types. As a result, two function types defined with different linkages can be treated as identical, which contradicts the standard's specifications.

Consequences of the Issue

This non-compliance can lead to static assertions failing, as shown in an example where a static assertion failed to recognize the difference in linkage. Additionally, function overloads that depend on linkage distinctions can result in erroneous compilation failures.

Proposed Changes to the Standard

The article suggests that the issue may lie with the C++ standard itself rather than the compilers. An update to the standard could clarify the handling of language linkage and potentially make it implementation-defined, avoiding breaking changes to existing compilers.

Conclusion

The inconsistency between C++ language specifications and compiler implementations raises important questions about the need for the standard to evolve. GCC and Clang face constraints that prevent them from altering their behavior due to compatibility with existing ABI, necessitating a review and potential revision of the relevant standard section.

✨ This summary was generated by AI from the outlets' reporting listed below. It is not independently verified and may contain errors — check the original sources. How BrevFeed works →

Reporting from

GCC and Clang do not support the C++ standard's requirement for distinct language linkages for function types, allowing C and C++ function types to be treated as identical. This issue can lead to compilation problems and violates the one definition rule in C++. The standard may need to be updated to clarify language linkage implementation requirements.