From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18579 invoked by alias); 15 Apr 2002 14:16:07 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 18545 invoked by uid 71); 15 Apr 2002 14:16:04 -0000 Resent-Date: 15 Apr 2002 14:16:03 -0000 Resent-Message-ID: <20020415141603.18543.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-To: nobody@gcc.gnu.org Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org, aj@suse.de Resent-Reply-To: gcc-gnats@gcc.gnu.org, pthomas@suse.de Received:(qmail 16964 invoked by uid 61); 15 Apr 2002 14:09:42 -0000 Message-Id:<20020415140942.16963.qmail@sources.redhat.com> Date: Mon, 15 Apr 2002 07:16:00 -0000 From: pthomas@suse.de Reply-To: pthomas@suse.de To: gcc-gnats@gcc.gnu.org Cc: aj@suse.de X-Send-Pr-Version:gnatsweb-2.9.3 (1.1.1.1.2.31) X-GNATS-Notify:aj@suse.de Subject: c++/6307: gcc looses const qualifier, thus rejecting valid code. X-SW-Source: 2002-04/txt/msg00772.txt.bz2 List-Id: >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::sort(int (*)(T*&, T*&), int, int) [with T = int]' gcc31_bug_const.cc: In member function `void Link_array::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::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 Link_array { public: Link_array () {} Link_array (Link_array 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 void Link_array::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 clashes; clashes.sort (Note_column::shift_compare); return 1; } int main() { return 0; }