Opened 6 years ago

Closed 6 years ago

Last modified 4 years ago

#9698 closed build error (fixed)

Compiler error in wxDebugContext

Reported by: Peter_Most Owned by:
Priority: low Milestone:
Component: build Version: stable-latest
Keywords: wxDebugContext Cc: Peter_Most@…
Blocked By: Blocking:
Patch: yes

Description

When using memory tracing the following compiler error occurs:

../src/common/memory.cpp: In member function ‘void wxMemStruct::Dump()’:
../src/common/memory.cpp:373: error: no matching function for call to ‘wxDebugContext::OutputDumpLine(wxString&)’
../include/wx/memory.h:311: note: candidates are: static void wxDebugContext::OutputDumpLine(const wxChar*, ...)
../src/common/memory.cpp:384: error: no matching function for call to ‘wxDebugContext::OutputDumpLine(wxString&)’
../include/wx/memory.h:311: note: candidates are: static void wxDebugContext::OutputDumpLine(const wxChar*, ...)
../src/common/memory.cpp: In static member function ‘static bool wxDebugContext::Dump()’:
../src/common/memory.cpp:596: error: invalid cast from type ‘wxString’ to type ‘const wxChar*’
../src/common/memory.cpp:597: error: invalid cast from type ‘wxString’ to type ‘const wxChar*’
../src/common/memory.cpp: In static member function ‘static bool wxDebugContext::PrintStatistics(bool)’:
../src/common/memory.cpp:652: error: invalid cast from type ‘wxString’ to type ‘const wxChar*’
../src/common/memory.cpp:653: error: invalid cast from type ‘wxString’ to type ‘const wxChar*’
../src/common/memory.cpp: In static member function ‘static bool wxDebugContext::PrintClasses()’:
../src/common/memory.cpp:746: error: invalid cast from type ‘wxString’ to type ‘const wxChar*’

I'm assuming those came from the changes to the wxString interface for 3.0.

Attachments (2)

ticket_9698.patch download (2.3 KB) - added by Peter Most 6 years ago.
ticket_9698-2.patch download (1.2 KB) - added by Peter Most 6 years ago.

Download all attachments as: .zip

Change History (7)

Changed 6 years ago by Peter Most

comment:1 Changed 6 years ago by vadz

  • Resolution set to fixed
  • Status changed from new to closed

I think just using implicit casts should work, shouldn't it?

Could you please try r54560 and reopen this if there are still any problems remaining?

Thanks!

Changed 6 years ago by Peter Most

comment:2 Changed 6 years ago by Peter Most

  • Cc Peter_Most@… added
  • Resolution fixed deleted
  • Status changed from closed to reopened

Sorry, still doesn't compile. The implicit conversion operators from wxString are only enabled in a non STL-Build (ie. --disable-stl). I configured it with:

--enable-debug --enable-debug_flag --enable-mem_tracing --disable-gui --disable-debug_cntxt
--enable-stl --enable-log --enable-std_iostreams --enable-std_string

(Sorry for not giving that info in the first place)

But there might be a bigger problem here! If a user first configures with --disable-stl, then he can use the implicit conversion operators. But if he later decides to use the stl and configures it with --enable-stl, then his code will not compile anymore.

The implicit conversion operator:

// implicit conversion to C string
wxString::operator wxCStrData() const;

doesn't help either, because if I remember correctly, C++ applies an user defined conversion operator only once and not twice (should be in ISOIEC14882-1998 13.3.3.1.2 Userdefined conversion sequences [over.ics.user]).
So in the conversion sequence:

wxString::operator wxCStrData() const --> wxCStrData::operator const char*() const

the second conversion will not be used anymore!

Since I'm here to fix bugs, I attached another patch.

comment:3 Changed 6 years ago by Peter Most

  • Status changed from reopened to confirmed

Is something missing in the second patch (ticket_9698-2.patch) ?

comment:4 Changed 6 years ago by vadz

  • Resolution set to fixed
  • Status changed from confirmed to closed

Thanks, applied as r54599.

comment:5 Changed 4 years ago by wxsite

  • Reporter changed from Peter Most to Peter_Most
Note: See TracTickets for help on using tickets.