public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c++/6307: gcc looses const qualifier, thus rejecting valid code.
@ 2002-04-15 7:16 pthomas
0 siblings, 0 replies; 2+ messages in thread
From: pthomas @ 2002-04-15 7:16 UTC (permalink / raw)
To: gcc-gnats; +Cc: aj
>Number: 6307
>Category: c++
>Synopsis: gcc looses const qualifier, thus rejecting valid code.
>Confidential: no
>Severity: critical
>Priority: medium
>Responsible: unassigned
>State: open
>Class: rejects-legal
>Submitter-Id: net
>Arrival-Date: Mon Apr 15 07:16:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Philipp Thomas, SuSE Linux Ag
>Release: 3.1 20020408 (prerelease)
>Organization:
>Environment:
i486-suse-linux
>Description:
When compiling the attached test case, gcc fails with
gcc31_bug_const.cc: In member function `int Collision::automatic_shift()':
gcc31_bug_const.cc:38: invalid conversion from `int (*)(int* const&, int*
const&)' to `int (*)(int*&, int*&)'
gcc31_bug_const.cc:38: initializing argument 1 of `void
Link_array<T>::sort(int (*)(T*&, T*&), int, int) [with T = int]'
gcc31_bug_const.cc: In member function `void Link_array<T>::sort(int (*)(T*&,
T*&), int, int) [with T = int]':
gcc31_bug_const.cc:38: instantiated from here
gcc31_bug_const.cc:29: invalid conversion from `int (*)(int* const&, int*
const&)' to `int (*)(int*&, int*&)'
gcc31_bug_const.cc:29: initializing argument 1 of `void
Link_array<T>::sort(int (*)(T*&, T*&), int, int) [with T = int]'
AFAICS, this is valid code and gcc looses the const somewhere.
>How-To-Repeat:
Compile attached file with c++.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="gcc31_bug_const.cc"
Content-Disposition: inline; filename="gcc31_bug_const.cc"
template<class T>
class Link_array
{
public:
Link_array () {}
Link_array (Link_array<T> const &src) {}
// quicksort.
void sort (int (*compare) (T *const&,T *const&),
int lower = -1, int upper = -1);
};
class Note_column
{
public:
static int shift_compare (int *const &, int *const &) {};
};
class Collision // interface
{
public:
int automatic_shift ();
};
template<class T> void
Link_array<T>::sort (int (*compare) (T *const&,T *const&),
int lower, int upper)
{
int last = lower;
sort (compare, lower, last-1);
}
int
Collision::automatic_shift ()
{
int d = 1;
Link_array<int> clashes;
clashes.sort (Note_column::shift_compare);
return 1;
}
int main()
{
return 0;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: c++/6307: gcc looses const qualifier, thus rejecting valid code.
@ 2002-04-17 2:52 pthomas
0 siblings, 0 replies; 2+ messages in thread
From: pthomas @ 2002-04-17 2:52 UTC (permalink / raw)
To: aj, gcc-bugs, gcc-prs, nobody, pthomas
Synopsis: gcc looses const qualifier, thus rejecting valid code.
State-Changed-From-To: open->closed
State-Changed-By: pthomas
State-Changed-When: Wed Apr 17 02:52:45 2002
State-Changed-Why:
Dupplicate of c++/6331
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6307
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2002-04-17 9:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-15 7:16 c++/6307: gcc looses const qualifier, thus rejecting valid code pthomas
2002-04-17 2:52 pthomas
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).