Bug in code or bug in cl?

Discussion in 'C++' started by Gus Gassmann, Feb 9, 2010.

  1. Gus Gassmann

    Gus Gassmann Guest

    I have a short code snippet here that gives me a curious compiler
    warning.

    int DGG_nicefyConstraint( const void */*solver_ptr*/,
    DGG_data_t *data,
    DGG_constraint_t *cut)

    The cl compiler in MSVisualStudio v9 reports

    cgltwomir.cpp(1067) : warning C4138: '*/' found outside of comment.

    Line 1067 is the first line of the code snippet. I am not sure if it
    complains about the first occurence of '*/' in this line or the
    second. I am not even sure if the code is correct or what it means.
    Can someone help?

    TIA
    Gus Gassmann, Feb 9, 2010
    #1
    1. Advertising

  2. Gus Gassmann wrote:
    > I have a short code snippet here that gives me a curious compiler
    > warning.
    >
    > int DGG_nicefyConstraint( const void */*solver_ptr*/,


    Make it

    int DGG_nicefyConstraint( const void * /*solver_ptr*/,

    The tokenizer sees the first asterisk and keeps reading more until it
    can't form a complete token any longer. So, the following slash (that
    you intended as the beginning of the comment) is added to the asterisk
    and is interpreted as a closing for a non-existent comment.

    > DGG_data_t *data,
    > DGG_constraint_t *cut)
    >
    > The cl compiler in MSVisualStudio v9 reports
    >
    > cgltwomir.cpp(1067) : warning C4138: '*/' found outside of comment.
    >
    > Line 1067 is the first line of the code snippet. I am not sure if it
    > complains about the first occurence of '*/' in this line or the
    > second. I am not even sure if the code is correct or what it means.


    It would be correct if you added a space after the first asterisk. The
    name of the argument is optional. Apparently the function does not use
    the first argument, so the author commented the name out to prevent the
    warning about an unused argument.

    V
    --
    Please remove capital 'A's when replying by e-mail
    I do not respond to top-posted replies, please don't ask
    Victor Bazarov, Feb 9, 2010
    #2
    1. Advertising

  3. Gus Gassmann

    James Kanze Guest

    On 9 Feb, 19:32, Victor Bazarov <> wrote:
    > Gus Gassmann wrote:
    > > I have a short code snippet here that gives me a curious
    > > compiler warning.


    > > int DGG_nicefyConstraint( const void */*solver_ptr*/,


    > Make it


    > int DGG_nicefyConstraint( const void * /*solver_ptr*/,


    > The tokenizer sees the first asterisk and keeps reading more
    > until it can't form a complete token any longer. So, the
    > following slash (that you intended as the beginning of the
    > comment) is added to the asterisk and is interpreted as a
    > closing for a non-existent comment.


    > > DGG_data_t *data,
    > > DGG_constraint_t *cut)


    > > The cl compiler in MSVisualStudio v9 reports


    > > cgltwomir.cpp(1067) : warning C4138: '*/' found outside of comment.


    > > Line 1067 is the first line of the code snippet. I am not
    > > sure if it complains about the first occurence of '*/' in
    > > this line or the second. I am not even sure if the code is
    > > correct or what it means.


    > It would be correct if you added a space after the first asterisk.


    It's correct anyway. There is no */ token in C++, so the max
    munch rule doesn't apply. And the compiler is only warning;
    presumably the authors of the compiler felt that most occurances
    of */ would be closing comments, and that one outside of a
    comment was probably due to someone having forgotten to open the
    comment.

    --
    James Kanze
    James Kanze, Feb 9, 2010
    #3
  4. -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    Gus Gassmann wrote:

    > I have a short code snippet here that gives me a curious compiler
    > warning.
    >
    > int DGG_nicefyConstraint( const void */*solver_ptr*/,
    > DGG_data_t *data,
    > DGG_constraint_t *cut)
    >
    > The cl compiler in MSVisualStudio v9 reports
    >
    > cgltwomir.cpp(1067) : warning C4138: '*/' found outside of comment.
    >
    > Line 1067 is the first line of the code snippet. I am not sure if it
    > complains about the first occurence of '*/' in this line or the
    > second. I am not even sure if the code is correct or what it means.
    > Can someone help?
    >
    > TIA


    There is no bug. It's a warning, not an error.
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.9 (GNU/Linux)

    iEYEARECAAYFAkt2wy0ACgkQm4klUUKw07CJzQCfbRzqxjKHY8U+PT5GD8UwlKvw
    +VQAn1fnt5u1OcrhtfOepVpktp7qSN27
    =Fzx+
    -----END PGP SIGNATURE-----
    Michael Tsang, Feb 13, 2010
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Q2FybG8gTWFyY2hlc29uaQ==?=

    Fire Code behind code AND Javascript code associated to a Button Click Event

    =?Utf-8?B?Q2FybG8gTWFyY2hlc29uaQ==?=, Feb 10, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    21,176
    =?Utf-8?B?Q2FybG8gTWFyY2hlc29uaQ==?=
    Feb 11, 2004
  2. John

    Re: BUG? OR NOT A BUG?

    John, Sep 20, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    536
  3. RedEye
    Replies:
    2
    Views:
    567
    Jason Kester
    Dec 13, 2005
  4. keithb
    Replies:
    1
    Views:
    888
    Bruce Barker
    Mar 29, 2006
  5. DarkSpy
    Replies:
    4
    Views:
    874
    tom_usenet
    Jun 27, 2003
Loading...

Share This Page