Skip to content

winrt::impl::slim_source_location::current default arguments has an ODR violation when mixing cpp language standards #1445

@dmachaj

Description

@dmachaj

Version

(not yet released at this time)

Summary

I am filing this as a follow-up issue after #1444 is merged. That PR is eliminating a serious ODR issue and is replacing it with a minor ODR issue. There is no longer ABI incompatibility based on language standard or defining WINRT_NO_SOURCE_LOCATION. However, there is a minor new ODR incompatibility when it comes to the default arguments to the current() method.

The value of the default arguments are separate from the type of the method itself, so this misbehavior is minor at worst. When all translation units agree then there is no ODR and everything is great. When mixing different versions (e.g. cpp17 and cpp20 static libraries) the behavior becomes undefined. If a given method is only used by one library or the other then the source location value for that library will be in effect. If a method is used by both libraries then the linker will choose which version is linked (with or without source location).

tl;dr - If you use cppwinrt in both cpp17 and cpp20 code and link them together then sometimes source location will be missing, and sometimes it will be present. Your mileage may vary.

Reproducible example

No response

Expected behavior

No response

Actual behavior

No response

Additional comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions