default value under linux

Discussion in 'C++' started by Onyxx, Apr 4, 2013.

  1. Onyxx

    Onyxx Guest

    I kind of remember that in the following function signature, the optional input param will always be equal to its default value under Linux.

    int funct(const int param = 1)
    {

    }
     
    Onyxx, Apr 4, 2013
    #1
    1. Advertising

  2. Onyxx

    Onyxx Guest

    So basically the following function would always return 1 on Linux.

    int funct(const int param = 1)
    {
    return param;
    }

    I think it is because the compiler is doing some optimization.

    Or may be it was a similar case ... Does someone know in which situation this would happen ?
     
    Onyxx, Apr 4, 2013
    #2
    1. Advertising

  3. Onyxx

    Jorgen Grahn Guest

    On Thu, 2013-04-04, Onyxx wrote:
    > So basically the following function would always return 1 on Linux.
    >
    > int funct(const int param = 1)
    > {
    > return param;
    > }
    >
    > I think it is because the compiler is doing some optimization.
    >
    > Or may be it was a similar case ... Does someone know in which
    > situation this would happen ?


    It can only happen if you have a seriously broken compiler.
    And it seems unlikely that g++ has had such a bug in the last decade,
    although perhaps a superficially similar case could have.

    Why are you asking, by the way? Are you really trying to ask about
    something else, such as whether Linux is a useful platform, or g++ a
    useful compiler?

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
     
    Jorgen Grahn, Apr 4, 2013
    #3
  4. Onyxx

    Onyxx Guest

    I remember vaguely a similar bug that I had on Linux but not on Windows. Itshould have been something different.

    Thanks for the answer

    Le jeudi 4 avril 2013 12:40:37 UTC+1, Jorgen Grahn a ?crit?:
    > On Thu, 2013-04-04, Onyxx wrote:
    >
    > > So basically the following function would always return 1 on Linux.

    >
    > >

    >
    > > int funct(const int param = 1)

    >
    > > {

    >
    > > return param;

    >
    > > }

    >
    > >

    >
    > > I think it is because the compiler is doing some optimization.

    >
    > >

    >
    > > Or may be it was a similar case ... Does someone know in which

    >
    > > situation this would happen ?

    >
    >
    >
    > It can only happen if you have a seriously broken compiler.
    >
    > And it seems unlikely that g++ has had such a bug in the last decade,
    >
    > although perhaps a superficially similar case could have.
    >
    >
    >
    > Why are you asking, by the way? Are you really trying to ask about
    >
    > something else, such as whether Linux is a useful platform, or g++ a
    >
    > useful compiler?
    >
    >
    >
    > /Jorgen
    >
    >
    >
    > --
    >
    > // Jorgen Grahn <grahn@ Oo o. . .
    >
    > \X/ snipabacken.se> O o .
     
    Onyxx, Apr 4, 2013
    #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. hshdude
    Replies:
    12
    Views:
    1,107
    Dimitri Maziuk
    Nov 4, 2004
  2. bronby
    Replies:
    1
    Views:
    667
    Andrew Thompson
    Jul 15, 2005
  3. Michael Ahlers
    Replies:
    1
    Views:
    5,758
    Martin Honnen
    Jul 12, 2004
  4. C Gillespie
    Replies:
    3
    Views:
    440
    Peter Hansen
    Mar 22, 2005
  5. Luke Kenneth Casson Leighton
    Replies:
    0
    Views:
    384
    Luke Kenneth Casson Leighton
    Jan 15, 2009
Loading...

Share This Page