Re: RFC, problem with g++4

2005-07-30 Thread Jaakko Niemi
Followups to #320630. --j -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Re: RFC, problem with g++4

2005-07-30 Thread Florian Weimer
* Goswin von Brederlow: > The proper use of this construct seems to be: > > template > struct Foo { > static const unsigned N = T::N; > char bar[N]; > }; > > struct Bla { > static const unsigned N; > }; > > const unsigned Bla::N = 10; > > int main() { > Foo foo; > } This program is ill-f

Re: RFC, problem with g++4

2005-07-29 Thread Goswin von Brederlow
Florian Weimer <[EMAIL PROTECTED]> writes: > * Goswin von Brederlow: > >>> This was once desirable because you couldn't declare real constants in >>> classes. Today, >>> >>> template >>> struct Foo >>> { >>> static const unsigned N = T::N; >>> char bar[N]; >>> }; >>> >>> works an

Re: RFC, problem with g++4

2005-07-29 Thread Jaakko Niemi
On Fri, 29 Jul 2005, Florian Weimer wrote: > * Jaakko Niemi: > > > So, if I'm understanding this and the discussion > > that followed correctly, we should change the > > enum to constants. > > Eh, no, sorry. This will almost certainly break things because this > is a C header, not C++. Sorr

Re: RFC, problem with g++4

2005-07-29 Thread Florian Weimer
* Jaakko Niemi: > So, if I'm understanding this and the discussion > that followed correctly, we should change the > enum to constants. Eh, no, sorry. This will almost certainly break things because this is a C header, not C++. Just use #defines, as suggested by Brian M. Carlson in <[EMAIL P

Re: RFC, problem with g++4

2005-07-29 Thread Jaakko Niemi
On Fri, 29 Jul 2005, Florian Weimer wrote: > This was once desirable because you couldn't declare real constants in > classes. Today, > > template > struct Foo > { > static const unsigned N = T::N; > char bar[N]; > }; > > works and the enum trick lost its importance. So, if I'

Re: RFC, problem with g++4

2005-07-29 Thread Antti-Juhani Kaijanaho
On 20050729T17+0200, Florian Weimer wrote: > > The problem is, your trick doesn't work outside templates, > > Huh? [After testing it:] I'll be damned. I was sure I was right :) -- Antti-Juhani Kaijanaho, Debian developer http://kaijanaho.info/antti-juhani/blog/en/debian signature.asc

Re: RFC, problem with g++4

2005-07-29 Thread Florian Weimer
* Olaf van der Spek: >> Only if the compiler knows all uses of that constant. With dynamic >> linking, you can't know that very easily. > > I thought you meant optimizing code that accesses it for performance. > I don't think the space optimization is important. The space optimization is crucia

Re: RFC, problem with g++4

2005-07-29 Thread Olaf van der Spek
On 7/29/05, Antti-Juhani Kaijanaho <[EMAIL PROTECTED]> wrote: > On 20050729T16+0200, Olaf van der Spek wrote: > > On 7/29/05, Goswin von Brederlow <[EMAIL PROTECTED]> wrote: > > > Florian Weimer <[EMAIL PROTECTED]> writes: > > > Doesn't that still make N a real variable in memory and does not g

Re: RFC, problem with g++4

2005-07-29 Thread Florian Weimer
* Thiemo Seufer: >> With dynamic linking, you can't know that very easily. > > The compiler knows nothing about dynamic linking, since this is outside > the compilation unit. Indeed, and the fact that you can use such a constant as a template argument just stresses that it's a compile-time thing.

Re: RFC, problem with g++4

2005-07-29 Thread Thiemo Seufer
Antti-Juhani Kaijanaho wrote: > On 20050729T16+0200, Olaf van der Spek wrote: > > On 7/29/05, Goswin von Brederlow <[EMAIL PROTECTED]> wrote: > > > Florian Weimer <[EMAIL PROTECTED]> writes: > > > Doesn't that still make N a real variable in memory and does not get > > > optimized away like enu

Re: RFC, problem with g++4

2005-07-29 Thread Florian Weimer
* Antti-Juhani Kaijanaho: > That is not a new trick, I'm fairly sure that was legal when I first > learned of the enum idiom. It's illegal according to The C++ Programming Language, Second Edition (which was published in 1991). I didn't claim the trick was new. 8-) > The problem is, your trick

Re: RFC, problem with g++4

2005-07-29 Thread Antti-Juhani Kaijanaho
On 20050729T151821+0200, Florian Weimer wrote: > Today, > > template > struct Foo > { > static const unsigned N = T::N; > char bar[N]; > }; > > works and the enum trick lost its importance. That is not a new trick, I'm fairly sure that was legal when I first learned of the enum

Re: RFC, problem with g++4

2005-07-29 Thread Florian Weimer
* Goswin von Brederlow: >> This was once desirable because you couldn't declare real constants in >> classes. Today, >> >> template >> struct Foo >> { >> static const unsigned N = T::N; >> char bar[N]; >> }; >> >> works and the enum trick lost its importance. > > Doesn't that sti

Re: RFC, problem with g++4

2005-07-29 Thread Antti-Juhani Kaijanaho
On 20050729T16+0200, Olaf van der Spek wrote: > On 7/29/05, Goswin von Brederlow <[EMAIL PROTECTED]> wrote: > > Florian Weimer <[EMAIL PROTECTED]> writes: > > Doesn't that still make N a real variable in memory and does not get > > optimized away like enums? > > I think it's (only) required to

Re: RFC, problem with g++4

2005-07-29 Thread Olaf van der Spek
On 7/29/05, Goswin von Brederlow <[EMAIL PROTECTED]> wrote: > Florian Weimer <[EMAIL PROTECTED]> writes: > Doesn't that still make N a real variable in memory and does not get > optimized away like enums? I think it's (only) required to have an address. I don't see why the compiler can't optimize

Re: RFC, problem with g++4

2005-07-29 Thread Goswin von Brederlow
Florian Weimer <[EMAIL PROTECTED]> writes: > * Antti-Juhani Kaijanaho: > >> The anon enumeration trick has been an established C++ idom for years >> (ISTR, but cannot check now, even Stroustrup himself advocating it). > > This was once desirable because you couldn't declare real constants in > cla

Re: RFC, problem with g++4

2005-07-29 Thread Florian Weimer
* Antti-Juhani Kaijanaho: > The anon enumeration trick has been an established C++ idom for years > (ISTR, but cannot check now, even Stroustrup himself advocating it). This was once desirable because you couldn't declare real constants in classes. Today, template struct Foo { static

Re: RFC, problem with g++4

2005-07-29 Thread Goswin von Brederlow
Antti-Juhani Kaijanaho <[EMAIL PROTECTED]> writes: > On 20050729T083332+, Brian M. Carlson wrote: >> Of course, I could be persuaded that the enumeration is a good idea, but >> I don't see what problem it solves, and it only seems to cause them. > > The anon enumeration trick has been an estab

Re: RFC, problem with g++4

2005-07-29 Thread Antti-Juhani Kaijanaho
On 20050729T083332+, Brian M. Carlson wrote: > Of course, I could be persuaded that the enumeration is a good idea, but > I don't see what problem it solves, and it only seems to cause them. The anon enumeration trick has been an established C++ idom for years (ISTR, but cannot check now, even

Re: RFC, problem with g++4

2005-07-29 Thread Jaakko Niemi
On Fri, 29 Jul 2005, Petri Latvala wrote: > One option would be to make wrap take an int always, if that's > feasible. Or long. Or unsigned versions of those. sfs upstream might want to do that for portability. I'm wondering what are the consequences of making that enum named.. can anyone see w

Re: RFC, problem with g++4

2005-07-29 Thread Brian M. Carlson
On Fri, 2005-07-29 at 10:55 +0300, Jaakko Niemi wrote: > Hello, > > /usr/include/sys/socket.h has this: > > - > /* The following constants should be used for the second parameter of >`shutdown'. */ > enum > { > SHUT_RD = 0, /* No more receptions. */ > #define SHUT_R

Re: RFC, problem with g++4

2005-07-29 Thread Petri Latvala
On Fri, Jul 29, 2005 at 10:55:36AM +0300, Jaakko Niemi wrote: > Hello, > > /usr/include/sys/socket.h has this: [anonymous enum def] > rexchan.C:254: error: no matching function for call to 'wrap(unixfd* > const, void (unixfd::*)(int, int), )' > > rexchan.C:254 is: > > paios_out->setwcb (w