Investigate possible UB or MSVC bug in idl_test exposed by MSVC upgrade

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Major - P3
    • 8.3.0-rc0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Server Programmability
    • Fully Compatible
    • Programmability 2026-01-05
    • 200
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      In a patch build here testing an upgrade of MSVC, we observed some failures in idl_test. From some digging, the problem is that we're taking the wrong branch in the initialization of the _serializationContext member of BypassReplyStruct. The generated code for that looks like this:

      _serializationContext(serializationContext.value_or(_isCommandReply ? SerializationContext::stateCommandReply() : SerializationContext::stateDefault())),
      

      _isCommandReply is a static constexpr bool member and is true, but we take the false branch (confirmed through some logging in a local run). This only happens with optimization enabled. If I add another pointless int member to the class and make its initialization dependent on _isCommandReply, then we start taking the correct branch.

      These observations may point to the compiler inferring UB somewhere if _isCommandReply is true.

            Assignee:
            Ryan Berryhill
            Reporter:
            Ryan Berryhill
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: