public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/3600: g++ 2.95.3 complains about "unsigned long( 25 )"
@ 2001-07-07  6:42 lerdsuwa
  0 siblings, 0 replies; 2+ messages in thread
From: lerdsuwa @ 2001-07-07  6:42 UTC (permalink / raw)
  To: crawford, gcc-bugs, gcc-prs, nobody

Synopsis: g++ 2.95.3 complains about "unsigned long( 25 )"

State-Changed-From-To: open->closed
State-Changed-By: lerdsuwa
State-Changed-When: Sat Jul  7 06:42:22 2001
State-Changed-Why:
    Not a bug.  According to the standard, section 5.2.3 Explicit
    type conversion (functional notation) paragraph 1:
      A simple-type-specifier (7.1.5) followed by a parenthesized
      expression-list constructs a value of the specified type
      given the expression list.  If the expression list is a
      single expression, the type conversion expression is
      equivalent (in definedness, and if defined in meaning)
      to the corresponding cast expression (5.4). ...
    
    And in 7.1.5.2 Simple type specifiers, para 1
      The simple type specifiers are
        simple-type-specifier:
          unsigned
          long
          <other valid tokens snipped>
    
    So only "unsigned(25)" or "long(25)" is allowed.  
    "unsigned long(25)" contains two simple-type-specifier's
    and therefore is forbid by the 5.2.3 para 1 of the standard.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3600&database=gcc


^ permalink raw reply	[flat|nested] 2+ messages in thread

* c++/3600: g++ 2.95.3 complains about "unsigned long( 25 )"
@ 2001-07-06 21:26 crawford
  0 siblings, 0 replies; 2+ messages in thread
From: crawford @ 2001-07-06 21:26 UTC (permalink / raw)
  To: gcc-gnats

>Number:         3600
>Category:       c++
>Synopsis:       g++ 2.95.3 complains about "unsigned long( 25 )"
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          rejects-legal
>Submitter-Id:   net
>Arrival-Date:   Fri Jul 06 21:26:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Michael D. Crawford
>Release:        g++ 2.95.3-5
>Organization:
>Environment:
CygWin on Windows NT Service Pack 6, Pentium III machine.

The gcc I have is from the latest CygWin as of a couple weeks
ago.  When 3.0 is available for CygWin I'll try that out too.  I
think a slackware package for 3.0 is available for my linux systems, so I'll
try that out sometime soon too.  I'm not up to building gcc right now.
>Description:
The code in file Foo.cpp calls unsigned long's conversion 
operator to cast an int to an unsigned long.  g++ complains:

Foo.cpp:7: parse error before "long"

The code in question compiles (and works) without complaint with Microsoft
Visual C++ version 6 service pack 5, as well is Metrowerks CodeWarrior
version 6.1 for Windows.

>How-To-Repeat:
g++ -c Foo.cpp
>Fix:
surround the unsigned long with parenthesis, so the "unsigned"
is grouped with "long" to make "unsigned long" a unit:

ul = (unsigned long)( 25 );

I'm not clear whether that continues to be unsigned longs
one-parameter constructor conversion operator or just an
old-fashioned c-style cast.

An alternative is to use a typedef that is (as typedef's must be)
a single token.  My application is written for the Win32 api, and in
Win32, there is a "typedef unsigned long ULONG;"

ul = ULONG( 25 );

it also works to use a c++ style static cast:

ul = static_cast< unsigned long >( 25 );

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: application/x-unknown-content-type-CodeWarrior_cpp; name="Foo.cpp"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="Foo.cpp"

dm9pZCBGb28oKTsNCg0Kdm9pZCBGb28oKQ0Kew0KCXVuc2lnbmVkIGxvbmcgdWw7DQoJDQoJdWwg
PSB1bnNpZ25lZCBsb25nKCAyNSApOw0KCQ0KCXJldHVybjsNCn0NCg==


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-07-07  6:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-07-07  6:42 c++/3600: g++ 2.95.3 complains about "unsigned long( 25 )" lerdsuwa
  -- strict thread matches above, loose matches on Subject: below --
2001-07-06 21:26 crawford

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).