This is the mail archive of the gcc-prs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

c++/729: compiler does not recognize variable definition



>Number:         729
>Category:       c++
>Synopsis:       compiler does not recognize variable definition
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Nov 03 03:46:00 PST 2000
>Closed-Date:
>Last-Modified:
>Originator:     Ronald Fischer
>Release:        gcc version 2.95.2 19991024 (release)
>Organization:
>Environment:
uname -a says:

SunOS ix05 5.7 Generic_106541-10 sun4u sparc SUNW,Ultra-1
>Description:
I use gcc 2.95.2 to compile the following program (maptest.cc):
  
 #include <map>
 #include <string>
 typedef  map<string, void*> NameMap;
 void foo(const char* name, void* info) {
     NameMap::value_type p(string(name),info);
 }
  
 The compiler complains:
  
 maptest.cc: In function `void foo(const char *, void *)':
 maptest.cc:5: type specifier omitted for parameter
  
 Obviously, it treats p as a declaration of a function returning
 a NameMap::value_type, instead of the definition of a
 variable of type NameMap::value_type. Indeed, if I use the syntax 
  
   NameMap::value_type p=NameMap::value_type(string(name),info); 
  
 or drop the explicit conversion, i.e.
  
   NameMap::value_type p(name,info);
  
 it compiles fine. I checked chapter 6.8 of the standard (ambiguity resolution), but the ambiguities mentioned there
 seem not to apply to my case.
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]