🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2575

Re: sizeof() on an array argument

#2575
From: Ulf Schuenemann
Date: Mon, 13 Nov 1995 18:06
42 lines
2318 bytes
In article <9531505.20142@mulga.cs.mu.OZ.AU>,
fjh@munta.cs.mu.OZ.AU (Fergus Henderson) writes:
[..]
|> The reason is that the type of `v' is converted from `char [N]' to
|> `char *' (see 8.3.5/3 in the April draft working paper).
[..]
|> That is not relevant in this example, since despite the declaration,
|> `v' is not an array.
[..]
|> values.  It is a special "adjustment" that is specified in 8.3.5/3,
|> not a conversion in the usual C++ sense of the word.

I'd prefere this "adjustment" to be DEPRECATED.

Treating a name different to its declaration (without saying a word)
is errorprone and leads users to confusion, like Theo Vosse.

> void Add(DataPoint* dp, char v[N])

Contratry to the intention, the compiler does NOT check, that Add
is called with a char-array of size N. The fact that C/C++ allows it,
while trating it as a simple (... char * v) leads to a dangerous feeling
of security.

(... char v[N]) is nothing more than a comment. For honesty this
information should be given that way (as comment) and not as a type.

As array-type-params widespread used, the most I'm hoping to get
is deprecation.


Ulf Schuenemann

--------------------------------------------------------------------
 ,_.   Ulf Schuenemann
#,  \  Fakultaet fuer Informatik, Technische Universitaet Muenchen, Germany.
 |   > email: schuenem@informatik.tu-muenchen.de
 v=-<  WWW:   http://hphalle2.informatik.tu-muenchen.de/~schuenem/
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <48804v$eu9@sunsystem5.informatik.tu-muenchen.de>
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
References: <vosse-1011951040220001@fslq01.fsw.leidenuniv.nl> <9531505.20142@mulga.cs.mu.OZ.AU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!in2.uu.net!bounce-back
Date: 13 Nov 95 18:06:42 GMT
Approved: fjh@cs.mu.oz.au
From: schuenem@informatik.tu-muenchen.de (Ulf Schuenemann)
Newsgroups: comp.std.c++
Subject: Re: sizeof() on an array argument
X-Original-Date:  13 Nov 1995 17:43:59 GMT
Organization: Technische Universitaet Muenchen, Germany
Message-ID: <48804v$eu9@sunsystem5.informatik.tu-muenchen.de>
References: <vosse-1011951040220001@fslq01.fsw.leidenuniv.nl> <9531505.20142@mulga.cs.mu.OZ.AU>
X-Auth: PGPMoose V1.1 PGP comp.std.c++
 iQBFAgUBMKeJReEDnX0m9pzZAQEilAF8Do109RjWRooHRE8hQyeadhQj76cTE6oU
 oZa+EjiopXwHtqIJFvVVXgPnoQVfbz02
 =ZPB3