[Libreoffice-bugs] [Bug 131117] Don't use static_cast with numeric literals

bugzilla-daemon at bugs.documentfoundation.org bugzilla-daemon at bugs.documentfoundation.org
Wed Mar 4 12:58:06 UTC 2020


https://bugs.documentfoundation.org/show_bug.cgi?id=131117

--- Comment #4 from Stephan Bergmann <sbergman at redhat.com> ---
(In reply to Mike Kaganski from comment #3)
> (In reply to Stephan Bergmann from comment #2)
> > Syntactically, functional cast can only be used if
> > wanted_type is a simple-type-specifier (e.g., it cannot be used if
> > wanted_type is "unsigned long").
> 
> Works fine for me with unsigned long(9) or unsigned short(9) in VS2019, and
> tested to produce the results of necessary type (e.g. in templated functions
> with deduced params, like std::max)

Retry with a compiler that does not have such a non-standard extension, then.

> > Apart from that, I at least have no clear
> > preference for either (functional cast is less verbose, though), and am not
> > sure whether such a cosmetic clean-up is worth it and wanted.
> 
> I personally dislike seeing those "static_casts" for what is not casting of
> value of one type to another type. I felt it a really easy hack for those
> who might want something very trivial to start. However, I don't mind
> closing this (and I added you to CC to learn your opinion on this).

static_cast<long>(1) /is/ about casting an object of type int to an object of
type long, just as much as long(1) is.  I fail to see what to dislike about the
former (apart from its verboseness) but not the latter.  I personally would
suggest closing this bug as WONTFIX.

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/libreoffice-bugs/attachments/20200304/2277a171/attachment.htm>


More information about the Libreoffice-bugs mailing list