Article View: comp.std.c++
Article #4014Re: Array function params and const qualifier
From: Jason Merrill
Date: Fri, 12 Apr 1996 17:48
Date: Fri, 12 Apr 1996 17:48
33 lines
2339 bytes
2339 bytes
>>>>> Steve Clamage <clamage@Eng.Sun.COM> writes: > In article rp3@mozart.wg.icl.co.uk, Adel El-Beik <A.El-Beik@man0506.wins.icl.co.uk> writes: >> I have a question concerning MSVC++ v.4.00 and the April DWP C++. >> >> The following code fails on MSVC++. It doesn't like line labelled 1. >> It complains with >> >> C:\array\array.cpp(16) : error C2664: 'func' : cannot convert parameter 1 >> from 'long [2][2]' to 'const long [][2]' (new behavior; please see help) > You have run into effectively the same rule that prohibits implicit > conversion from "T**" to "const T**". That prohibition is not new, > but is in the ISO/ANSI C standard, and has not been changed, since > it would open a hole in the type system. But converting long (*)[2] to const long (*)[2] is more like converting long ** to const long *const * than it is like converting long ** to const long **, because there is no way to modify the array -- there is, in fact, no array entity in memory, only two longs. A long (*)[2] points to two longs, whereas a const long (*)[2] points to two const longs. I don't see a constness hole there. I suspect this is an oversight. Jason [ comp.std.c++ is moderated. To submit articles: try just posting with ] [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ] [ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ] [ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ] [ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Technical Details
Message-ID:
<u9ratts5oh.fsf@yorick.cygnus.com>Path:
arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamageReferences:
<4ke06a$rp3@mozart.wg.icl.co.uk> <4kjqqa$bol@engnews1.Eng.Sun.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage From: jason@cygnus.com (Jason Merrill) Newsgroups: comp.std.c++ Subject: Re: Array function params and const qualifier Date: 12 Apr 1996 17:48:19 GMT Organization: Cygnus Support, Mountain View, CA Sender: jason@cygnus.com Approved: clamage@eng.sun.com (comp.std.c++) Message-ID: <u9ratts5oh.fsf@yorick.cygnus.com> References: <4ke06a$rp3@mozart.wg.icl.co.uk> <4kjqqa$bol@engnews1.Eng.Sun.COM> NNTP-Posting-Host: taumet.eng.sun.com Mime-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Nntp-Posting-Host: yorick.cygnus.com In-Reply-To: clamage@Eng.Sun.COM's message of 11 Apr 1996 17:27:59 PDT X-Newsreader: Gnus v5.0 X-Lines: 26 Content-Length: 1157 Originator: clamage@taumet