linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* c++ code - not getting compiled !!!!!!!!!
@ 2011-07-29  6:01 ratheesh kannoth
       [not found] ` <CALC0UT=JhhuEc2MNL9_PrhtgkF5eAqNgB8vtQ5ZK09DF8S8edA@mail.gmail.com>
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: ratheesh kannoth @ 2011-07-29  6:01 UTC (permalink / raw)
  To: linux-c-programming

#include <iostream>

using namespace std;

int main()
{
    int i;

    cout << "Enter value of i " << endl;
    cin >> i;

    if (i < 5)
        goto Sri;

    int j = 6;
    cout << "j = " << j << endl;

    cout << "Outside Sri" << endl;
    return 0;

Sri:
    cout << "Inside Sri" << endl;
    return 0;
}

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

* Re: c++ code - not getting compiled !!!!!!!!!
       [not found] ` <CALC0UT=JhhuEc2MNL9_PrhtgkF5eAqNgB8vtQ5ZK09DF8S8edA@mail.gmail.com>
@ 2011-07-29  6:26   ` ratheesh kannoth
  2011-07-29  6:44     ` Srinivasa T N
  0 siblings, 1 reply; 8+ messages in thread
From: ratheesh kannoth @ 2011-07-29  6:26 UTC (permalink / raw)
  To: Steve Graegert (スティーブ)
  Cc: linux-c-programming

g++ 2.cpp
2.cpp: In function 'int main()':
2.cpp:21: error: jump to label 'Sri'
2.cpp:13: error:   from here
2.cpp:15: error:   crosses initialization of 'int j'





2011/7/29 Steve Graegert (スティーブ) <graegerts@gmail.com>:
> Is it too much to ask for the actual error returned by the compiler?
>
>
> On Fri, Jul 29, 2011 at 08:01, ratheesh kannoth <ratheesh.ksz@gmail.com> wrote:
>> #include <iostream>
>>
>> using namespace std;
>>
>> int main()
>> {
>>    int i;
>>
>>    cout << "Enter value of i " << endl;
>>    cin >> i;
>>
>>    if (i < 5)
>>        goto Sri;
>>
>>    int j = 6;
>>    cout << "j = " << j << endl;
>>
>>    cout << "Outside Sri" << endl;
>>    return 0;
>>
>> Sri:
>>    cout << "Inside Sri" << endl;
>>    return 0;
>> }
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>

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

* Re: c++ code - not getting compiled !!!!!!!!!
  2011-07-29  6:01 c++ code - not getting compiled !!!!!!!!! ratheesh kannoth
       [not found] ` <CALC0UT=JhhuEc2MNL9_PrhtgkF5eAqNgB8vtQ5ZK09DF8S8edA@mail.gmail.com>
@ 2011-07-29  6:26 ` Srinivasa T N
  2011-07-29  6:40 ` Steve Graegert (スティーブ)
  2011-07-29  6:51 ` vipul kumar samar
  3 siblings, 0 replies; 8+ messages in thread
From: Srinivasa T N @ 2011-07-29  6:26 UTC (permalink / raw)
  To: ratheesh kannoth; +Cc: linux-c-programming

Post exactly what is the error you are facing.

Regards,
Seenu.

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

* Re: c++ code - not getting compiled !!!!!!!!!
  2011-07-29  6:01 c++ code - not getting compiled !!!!!!!!! ratheesh kannoth
       [not found] ` <CALC0UT=JhhuEc2MNL9_PrhtgkF5eAqNgB8vtQ5ZK09DF8S8edA@mail.gmail.com>
  2011-07-29  6:26 ` Srinivasa T N
@ 2011-07-29  6:40 ` Steve Graegert (スティーブ)
  2011-07-29  6:55   ` ratheesh kannoth
  2011-07-29  6:51 ` vipul kumar samar
  3 siblings, 1 reply; 8+ messages in thread
From: Steve Graegert (スティーブ) @ 2011-07-29  6:40 UTC (permalink / raw)
  To: ratheesh kannoth; +Cc: linux-c-programming

According to the C++ standard (6.7) you are allowed to jump past a declaration:

"It is possible to transfer into a block, but not in a way that
bypasses declarations with initialization. A program that jumps from a
point where a local variable with automatic storage duration is not in
scope to a point where it is in scope is ill-formed unless the
variable has POD type and is declared without an initializer."

    \Steve

--

Steve Graegert (スティーブ)
Mobile: +49 151 25335249
http://graegert.tel



On Fri, Jul 29, 2011 at 08:01, ratheesh kannoth <ratheesh.ksz@gmail.com> wrote:
> #include <iostream>
>
> using namespace std;
>
> int main()
> {
>    int i;
>
>    cout << "Enter value of i " << endl;
>    cin >> i;
>
>    if (i < 5)
>        goto Sri;
>
>    int j = 6;
>    cout << "j = " << j << endl;
>
>    cout << "Outside Sri" << endl;
>    return 0;
>
> Sri:
>    cout << "Inside Sri" << endl;
>    return 0;
> }
> --
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: c++ code - not getting compiled !!!!!!!!!
  2011-07-29  6:26   ` ratheesh kannoth
@ 2011-07-29  6:44     ` Srinivasa T N
  0 siblings, 0 replies; 8+ messages in thread
From: Srinivasa T N @ 2011-07-29  6:44 UTC (permalink / raw)
  To: ratheesh kannoth
  Cc: "Steve Graegert (スティーブ)",
	linux-c-programming

On 07/29/2011 11:56 AM, ratheesh kannoth wrote:
> #include<iostream>
>>>
>>>  using namespace std;
>>>
>>>  int main()
>>>  {
>>>      int i;
>>>
>>>      cout<<  "Enter value of i "<<  endl;
>>>      cin>>  i;
>>>
>>>      if (i<  5)
>>>          goto Sri;
>>>
>>>      int j = 6;

Changing it to two lines will make it work:
int j;
j = 6;

Regards,
Seenu.

>>>      cout<<  "j = "<<  j<<  endl;
>>>
>>>      cout<<  "Outside Sri"<<  endl;
>>>      return 0;
>>>
>>>  Sri:
>>>      cout<<  "Inside Sri"<<  endl;
>>>      return 0;
>>>  }


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

* Re: c++ code - not getting compiled !!!!!!!!!
  2011-07-29  6:01 c++ code - not getting compiled !!!!!!!!! ratheesh kannoth
                   ` (2 preceding siblings ...)
  2011-07-29  6:40 ` Steve Graegert (スティーブ)
@ 2011-07-29  6:51 ` vipul kumar samar
  3 siblings, 0 replies; 8+ messages in thread
From: vipul kumar samar @ 2011-07-29  6:51 UTC (permalink / raw)
  To: ratheesh kannoth; +Cc: linux-c-programming@vger.kernel.org

On 07/29/2011 11:31 AM, ratheesh kannoth wrote:
> #include<iostream>
>
> using namespace std;
>
> int main()
> {
>      int i;
>
>      cout<<  "Enter value of i "<<  endl;
>      cin>>  i;
>
>      if (i<  5)
>          goto Sri;
>
>      int j = 6;
  replace int j = 6;
with
	int j;
	j = 6;
  C++ standard: not able to bypasses declaration with initialization.

Regards
Vipul Samar
>      cout<<  "j = "<<  j<<  endl;
>
>      cout<<  "Outside Sri"<<  endl;
>      return 0;
>
> Sri:
>      cout<<  "Inside Sri"<<  endl;
>      return 0;
> }
> --
> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


-- 
I want another RE-WRITE on my CEASAR SALAD!!

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

* Re: c++ code - not getting compiled !!!!!!!!!
  2011-07-29  6:40 ` Steve Graegert (スティーブ)
@ 2011-07-29  6:55   ` ratheesh kannoth
  2011-07-29  7:00     ` Srinivasa T N
  0 siblings, 1 reply; 8+ messages in thread
From: ratheesh kannoth @ 2011-07-29  6:55 UTC (permalink / raw)
  To: Steve Graegert (スティーブ)
  Cc: linux-c-programming

Thanks steve.

This code snippet works fine  in newer version of g++. Am i right ?. i
am not sure abt the version of g++.

-Ratheesh

2011/7/29 Steve Graegert (スティーブ) <graegerts@gmail.com>:
> According to the C++ standard (6.7) you are allowed to jump past a declaration:
>
> "It is possible to transfer into a block, but not in a way that
> bypasses declarations with initialization. A program that jumps from a
> point where a local variable with automatic storage duration is not in
> scope to a point where it is in scope is ill-formed unless the
> variable has POD type and is declared without an initializer."
>
>    \Steve
>
> --
>
> Steve Graegert (スティーブ)
> Mobile: +49 151 25335249
> http://graegert.tel
>
>
>
> On Fri, Jul 29, 2011 at 08:01, ratheesh kannoth <ratheesh.ksz@gmail.com> wrote:
>> #include <iostream>
>>
>> using namespace std;
>>
>> int main()
>> {
>>    int i;
>>
>>    cout << "Enter value of i " << endl;
>>    cin >> i;
>>
>>    if (i < 5)
>>        goto Sri;
>>
>>    int j = 6;
>>    cout << "j = " << j << endl;
>>
>>    cout << "Outside Sri" << endl;
>>    return 0;
>>
>> Sri:
>>    cout << "Inside Sri" << endl;
>>    return 0;
>> }
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: c++ code - not getting compiled !!!!!!!!!
  2011-07-29  6:55   ` ratheesh kannoth
@ 2011-07-29  7:00     ` Srinivasa T N
  0 siblings, 0 replies; 8+ messages in thread
From: Srinivasa T N @ 2011-07-29  7:00 UTC (permalink / raw)
  To: ratheesh kannoth
  Cc: "Steve Graegert (スティーブ)",
	linux-c-programming

On 07/29/2011 12:25 PM, ratheesh kannoth wrote:
> Thanks steve.
>
> This code snippet works fine  in newer version of g++. Am i right ?. i
> am not sure abt the version of g++.
>
I am using g++ 4.5.1 on FC14 and the below code does not compile over there.

Use 'g++ --version' to know your g++ version.

Regards,
Seenu.

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

end of thread, other threads:[~2011-07-29  7:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-29  6:01 c++ code - not getting compiled !!!!!!!!! ratheesh kannoth
     [not found] ` <CALC0UT=JhhuEc2MNL9_PrhtgkF5eAqNgB8vtQ5ZK09DF8S8edA@mail.gmail.com>
2011-07-29  6:26   ` ratheesh kannoth
2011-07-29  6:44     ` Srinivasa T N
2011-07-29  6:26 ` Srinivasa T N
2011-07-29  6:40 ` Steve Graegert (スティーブ)
2011-07-29  6:55   ` ratheesh kannoth
2011-07-29  7:00     ` Srinivasa T N
2011-07-29  6:51 ` vipul kumar samar

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 NNTP newsgroup(s).