Uploaded image for project: 'Qt Creator'
  1. Qt Creator
  2. QTCREATORBUG-18835

Debbuging helper does not correctly display boost::variant

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • Qt Creator 4.3.0, Qt Creator 4.4.0-rc1
    • Debugger
    • Ubuntu 16.04 LTS

      Compiled with Clang 3.8

      Standard boost version 1.58 from the Ubuntu installation

       

    Description

      If the current alternative of the variant is a type with a reference than the value of the reference is wrong.

      In the following example struct A has a reference as a member (Minimal reproducer - simply put it in main.cpp):

      #include <boost/variant.hpp>
      
      struct B
      {
          int value;
      };
      
      struct A
      {
          B& ref;
      };
      
      int main()
      {
          B b{23};
          A a{b};
      
          boost::variant<int, A> wrong{a};
      
          return 0;
      }
      

      The output in the "Locals and Expression" is the following:

      a    @0x7fffffffe1e0    A
      - ref    @0x7fffffffe1e8    B &
      -- value    23    int
      b    @0x7fffffffe1e8    B
      - value    23    int
      wrong    @0x7fffffffe1d8    boost::variant<int, A>
      - ref    @0x7fffffffe1d8    B &
      -- value    -7704    int

      The value of "value" in the last line should also be 23. Instead "-7704" is printed. "-7704" converted to hex: 0x7fffffffe1e8. So the debugging helper simply prints the reference itself.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            hjk hjk
            jerryct Jerry Crunchtime
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes