Thread View: comp.std.c++
4 messages
4 total messages
Started by Mathew G Monroe
Sat, 14 Oct 1995 08:52
Two standards questions
Author: Mathew G Monroe
Date: Sat, 14 Oct 1995 08:52
Date: Sat, 14 Oct 1995 08:52
25 lines
1227 bytes
1227 bytes
First: Under the current draft standard are all const object only given
an internal linkage, unless they have previously been given external
linkage? I ask because I understood this was the case. But, GNU G++
(at least 2.7.0) doesn't strictly follow this. For example,
const char *messages[]={"Fun", "Stuff};
const char fun[]="message";
messages is made external, and fun is internal. This seems wrong to me,
both should be internal.
Second: By the current standard is the complex class a template? I ask
because old versions of GNU g++ and libg++ has complex not as a
template, yet g++ 2.7.0 and libg++ 2.7.0 make it a template.
Thanks,
matt
------
[ 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. ]
Re: Two standards questions
Author: Steve Clamage
Date: Sat, 14 Oct 1995 21:57
Date: Sat, 14 Oct 1995 21:57
46 lines
2117 bytes
2117 bytes
In article 4kTmzbC00iVD0Bmn4x@andrew.cmu.edu, Mathew G Monroe <mmex+@andrew.cmu.edu> writes:
>
>First: Under the current draft standard are all const object only given
>an internal linkage, unless they have previously been given external
>linkage? I ask because I understood this was the case.
Yes.
> But, GNU G++
>(at least 2.7.0) doesn't strictly follow this. For example,
>
>const char *messages[]={"Fun", "Stuff};
>const char fun[]="message";
>
>messages is made external, and fun is internal. This seems wrong to me,
>both should be internal.
No, GNU is correct. "messages" is not const, so it is made external.
That is "messages" is a non-const pointer to a const char. On the
other hand, "fun" is a const array of chars. The "const" applies to
the declarator which follows. In the first case, the declator is "*"
and in the second case it is "fun". Pointers and arrays are not
the same thing.
>
>Second: By the current standard is the complex class a template? I ask
>because old versions of GNU g++ and libg++ has complex not as a
>template, yet g++ 2.7.0 and libg++ 2.7.0 make it a template.
Yes, the current draft makes complex a template. The exact spelling
of the names and whether the spelling "complex" should be a typedef
to something like basic_complex<double> instead of the name of a
template was still under discussion the last time I checked.
---
Steve Clamage, stephen.clamage@eng.sun.com
---
[ 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. ]
Re: Two standards questions
Author: John Rickard
Date: Sun, 29 Oct 1995 15:08
Date: Sun, 29 Oct 1995 15:08
26 lines
1629 bytes
1629 bytes
Steve Clamage (clamage@Eng.Sun.COM) wrote:
: >const char *messages[]={"Fun", "Stuff};
: >const char fun[]="message";
: >
: >messages is made external, and fun is internal. This seems wrong to me,
: >both should be internal.
:
: No, GNU is correct. "messages" is not const, so it is made external.
: That is "messages" is a non-const pointer to a const char. On the
: other hand, "fun" is a const array of chars.
I'm sure it's intended that "fun" should have internal linkage. But
from a casual perusal of the draft (April working paper), it seems to
me that "fun" is not a const array of char, but an array of const
char, and that "fun" itself is _not_ const (although "fun[0]" is), and
so it has external linkage.
Have I missed something, or is this a mistake in the draft?
--
John Rickard
---
[ 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. ]
Re: Two standards questions
Author: J. Stephen Adamczyk
Date: Mon, 30 Oct 1995 13:36
Date: Mon, 30 Oct 1995 13:36
26 lines
1914 bytes
1914 bytes
In article <199510291313.NAA10621@anchovy.atml.co.uk> John Rickard <jrr@atml.co
.uk> writes:
>: >const char *messages[]={"Fun", "Stuff};
>: >const char fun[]="message";
>I'm sure it's intended that "fun" should have internal linkage. But
>from a casual perusal of the draft (April working paper), it seems to
>me that "fun" is not a const array of char, but an array of const
>char, and that "fun" itself is _not_ const (although "fun[0]" is), and
>so it has external linkage.
>
>Have I missed something, or is this a mistake in the draft?
You're right that the type of "fun" is "array of const char", but the
definition of "const-qualified" in C++ (unlike in C), when applied to an
array, tests the qualification of the underlying element type.
So the type of "fun" is const-qualified. It must be admitted that
the text relating to this in the WP [7.1.5.1 and 3.9.3] could be clearer,
but the precise question you bring up was brought before the full committee
and voted on, with the outcome as I described it.
Steve Adamczyk
---
[ 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. ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads