Re: Problem with local struct

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



jlh <jlh@xxxxxx> writes:

| I have troubles with a struct that is defined local to a function; see the code
| below.  I compiled it as follows with gcc-3.4.3
| 
| $ g++ -c -Wall -pedantic -ansi -Wextra problem.cpp
| problem.cpp: In function `void f()':
| problem.cpp:22: error: no matching function for call to `bind2nd(f()::Func, int)'
| ********************************************************************************
| However, if I move the entire "struct Func { ... }" block out of f() to global
| scope, it compiles fine.  Therefore I assume there's nothing wrong with Func
| itself, nor with the way it is being used in find_if().  I first thought that
| maybe GCC doesn't fully support structs local to functions yet, but I guess
| that's not the case, since I can properly instantiate and use Func, as shown
| below.

The short answer is: values for type template parameters cannot be
local classes. 

The long answer is: while GCC rightly rejected the code, there was a
slight bug which prevented it  from giving a better diagnostic.  Fixed
on mainline.

-- Gaby

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux