Hi!

On 04/22/11 11:17, David Timms wrote:
> I'm having trouble with building dvbcut [1] for Fedora 15. It occurs on 
> both an F15 beta machine and in mock from F14, on both i386 and x86_64.
> 
> The error is:
> =====
> dvbcut.cpp: In member function 'virtual void
> dvbcut::eventlistcontextmenu(QListBoxItem*, const QPoint&)':
> 
> dvbcut.cpp:1328:60: error: invalid initialization of reference of type
> 'EventListItem&' from expression of type 'const EventListItem'

Honestly, I don't understand why the code is casting something non-const
to something const, dereferencing it, and then passing that to a
non-const reference. That's one of these ugly pieces of C++ hackery I
really abhor.

The `const' is definitely wrong because the EventListItem& must refer to
a mutable object. Besides that, I don't know why Sven decided to use a
reference at that point.

Try removing the `const' keyword in line 1328 and recompiling. And don't
forget to let me know if that helps. I can't compile dvbcut with gcc
4.6.0 at all because g++ complains about ptrdiff_t not being a type in
several Qt header files the code includes. I suppose that's something
that should be fixed in the Qt3 source code, though, not in dvbcut.

New compilers suck, and new C++ compilers in particular.

> dvbcut.cpp: In member function 'void
> dvbcut::open(std::list<std::basic_string<char> >, std::string,
> std::string)':
> 
> dvbcut.cpp:1863:57: warning: ignoring return value of 'int chdir(const
> char*)', declared with attribute warn_unused_result [-Wunused-result]
> make[1]: *** [dvbcut.o] Error 1

If `chdir("/");' doesn't work, you're probably running a really strange
operating system.

> make[1]: Leaving directory `/builddir/build/BUILD/dvbcut-svn170/src'
> make: *** [all] Error 2
> =====
> The source [2] hasn't changed, so I guess gcc has gained the ability to
> check for this sort of problem, and exits.
> 
> Is that code dodgy/risky ?

In principle, using static_cast is unsafe because there's no type check.
You could use a dynamic_cast instead, but then you would have to check
if the result is != 0, and return otherwise. On the other hand, all list
members are supposed to be of type EventListItem, so you can as well
avoid the overhead of a run-time type check and use static_cast. Just
without the `const'.

-- 
Michael "Tired" Riepe <mich...@mr511.de>
X-Tired: Each morning I get up I die a little

------------------------------------------------------------------------------
Fulfilling the Lean Software Promise
Lean software platforms are now widely adopted and the benefits have been 
demonstrated beyond question. Learn why your peers are replacing JEE 
containers with lightweight application servers - and what you can gain 
from the move. http://p.sf.net/sfu/vmware-sfemails
_______________________________________________
DVBCUT-user mailing list
DVBCUT-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dvbcut-user

Reply via email to