public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/30928]  New: add casts to libc overloads
@ 2007-02-22 18:20 marc dot glisse at normalesup dot org
  2009-01-30 11:48 ` [Bug libstdc++/30928] " jakub at gcc dot gnu dot org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: marc dot glisse at normalesup dot org @ 2007-02-22 18:20 UTC (permalink / raw)
  To: gcc-bugs

Headers like cwchar add overloads to libc functions. Here I am interested in
the functions for which the standard C version takes a const pointer and
returns a non-const pointer and in C++ this version is replaced by one with
const everywhere and one with no const anywhere. For this, in c_std mode, g++
takes the libc version (instead of the full-const version) and adds an overload
which looks like:

  inline wchar_t*
  wcschr(wchar_t* __p, wchar_t __c)
  { return wcschr(const_cast<const wchar_t*>(__p), __c); }

The const_cast does not look very useful, but that is not the issue (it makes
it easier to understand, which is good). I was wondering whether it would be
acceptable to add a const_cast<wchar_t*> to the returned value? For the current
uses, it would do nothing. But now if a libc decided to provide the full-const
version when called by a c++ compiler, this would make it work.

Is there any real case where it would help? Well if bugs 27340 (trivial) and
30112 get fixed, with the following fixinclude rule, it would be the last thing
preventing from being able to set __cplusplus to either 1 or 199711L with no
testsuite regression (except for breaking the ABI) on solaris (I only checked
with 8). Of course this is only one way to achieve this (not the best one, but
it requires very little patching).

I will understand if you say no, I am just hoping for a "why not? It doesn't
hurt." (remember that in this bug I am only talking about adding some
const_casts, the __cplusplus value is an other issue)

The fixinclude rule, for info (I am not proposing it here, just mentionning it
for completeness)
/*
 *  Remove extern "C++" parts of solaris libc
 */
fix = {
    hackname  = solaris_no_extern_cpp;
    mach     = '*-*-solaris*';
    files     = "iso/ctype_iso.h";
    files     = "iso/limits_iso.h";
    files     = "iso/locale_iso.h";
    files     = "iso/math_iso.h";
    files     = "iso/setjmp_iso.h";
    files     = "iso/signal_iso.h";
    files     = "iso/stdarg_iso.h";
    files     = "iso/stddef_iso.h";
    files     = "iso/stdio_iso.h";
    files     = "iso/stdlib_iso.h";
    files     = "iso/string_iso.h";
    files     = "iso/time_iso.h";
    files     = "iso/wchar_iso.h";
    files     = "iso/wctype_iso.h";
    select    = 'extern[ \t]*"C\+\+"';
    shell     = "perl -e 'undef $/;$_=<>;s/extern[ \t]*\"C\\\+\\\+\"[
\t]*{([^{}]*{[^{}]*})*[^{}]*}//gs;print'";
    test_text = 'extern "C++" {void f();}';
};

(this uses perl, which I think has been part of the system for a very long
time, because I don't know how to do it with sed. I also don't know if the
files field accepts wildcards)


-- 
           Summary: add casts to libc overloads
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: marc dot glisse at normalesup dot org
  GCC host triplet: sparc-sun-solaris2.8


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30928


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-01-14 20:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-22 18:20 [Bug libstdc++/30928] New: add casts to libc overloads marc dot glisse at normalesup dot org
2009-01-30 11:48 ` [Bug libstdc++/30928] " jakub at gcc dot gnu dot org
2009-01-30 12:07 ` paolo dot carlini at oracle dot com
2009-01-30 12:09 ` paolo dot carlini at oracle dot com
2009-01-30 20:38 ` marc dot glisse at normalesup dot org
2010-01-14 17:24 ` paolo dot carlini at oracle dot com
2010-01-14 20:35 ` marc dot glisse at normalesup dot org
2010-01-14 20:44 ` paolo dot carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).