public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* sine.cpp isn't run good on gnu/g++, plz help
@ 2011-06-04  4:49 eric
  2011-06-04  6:14 ` Bryan Hundven
  2011-06-04 12:19 ` Jonathan Wakely
  0 siblings, 2 replies; 4+ messages in thread
From: eric @ 2011-06-04  4:49 UTC (permalink / raw)
  To: oualline; +Cc: gcc-help

Dear Steve Oualline:
  the book (Practical C++ Programming), AppendixD
computing sine using a power series
the program you listed on page 525, Example D-2 sin/sine.cpp
I tested on my linux/gnu-g++
----------------
eric@eric-laptop:~/practicalCpp/sin$ ./sine 3.141
x**1     3.141E+00
1!       1.000E+00
x**1/1! 3.141E+00
  total   3.141E+00

x**3     3.099E+01
3!       6.000E+00
x**3/3! 5.165E+00
*** stack smashing detected ***: ./sine terminated
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x50)[0x3d8390]
/lib/tls/i686/cmov/libc.so.6(+0xe233a)[0x3d833a]
./sine[0x8048e11]
./sine[0x8048bb5]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6)[0x30cbd6]
./sine[0x80488b1]
======= Memory map: ========
00110000-00134000 r-xp 00000000 08:01
8913271    /lib/tls/i686/cmov/libm-2.11.1.so
00134000-00135000 r--p 00023000 08:01
8913271    /lib/tls/i686/cmov/libm-2.11.1.so
00135000-00136000 rw-p 00024000 08:01
8913271    /lib/tls/i686/cmov/libm-2.11.1.so
0025b000-00276000 r-xp 00000000 08:01 8913086    /lib/ld-2.11.1.so
00276000-00277000 r--p 0001a000 08:01 8913086    /lib/ld-2.11.1.so
00277000-00278000 rw-p 0001b000 08:01 8913086    /lib/ld-2.11.1.so
002d7000-002f4000 r-xp 00000000 08:01 8912979    /lib/libgcc_s.so.1
002f4000-002f5000 r--p 0001c000 08:01 8912979    /lib/libgcc_s.so.1
002f5000-002f6000 rw-p 0001d000 08:01 8912979    /lib/libgcc_s.so.1
002f6000-00449000 r-xp 00000000 08:01
8913215    /lib/tls/i686/cmov/libc-2.11.1.so
00449000-0044a000 ---p 00153000 08:01
8913215    /lib/tls/i686/cmov/libc-2.11.1.so
0044a000-0044c000 r--p 00153000 08:01
8913215    /lib/tls/i686/cmov/libc-2.11.1.so
0044c000-0044d000 rw-p 00155000 08:01
8913215    /lib/tls/i686/cmov/libc-2.11.1.so
0044d000-00450000 rw-p 00000000 00:00 0 
00988000-00989000 r-xp 00000000 00:00 0          [vdso]
0099a000-00a83000 r-xp 00000000 08:01 12062387   /usr/lib/libstdc
++.so.6.0.13
00a83000-00a84000 ---p 000e9000 08:01 12062387   /usr/lib/libstdc
++.so.6.0.13
00a84000-00a88000 r--p 000e9000 08:01 12062387   /usr/lib/libstdc
++.so.6.0.13
00a88000-00a89000 rw-p 000ed000 08:01 12062387   /usr/lib/libstdc
++.so.6.0.13
00a89000-00a90000 rw-p 00000000 00:00 0 
08048000-0804a000 r-xp 00000000 08:01
5507048    /home/eric/practicalCpp/sin/sine
0804a000-0804b000 r--p 00001000 08:01
5507048    /home/eric/practicalCpp/sin/sine
0804b000-0804c000 rw-p 00002000 08:01
5507048    /home/eric/practicalCpp/sin/sine
08b07000-08b28000 rw-p 00000000 00:00 0          [heap]
b78bf000-b78c1000 rw-p 00000000 00:00 0 
b78d5000-b78d8000 rw-p 00000000 00:00 0 
bfc8f000-bfca4000 rw-p 00000000 00:00 0          [stack]
Aborted
eric@eric-laptop:~/practicalCpp/sin$ 
-------------------------------------------
that certainly is not what your book predict on page 523
plz help, Eric, US citizen

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

* Re: sine.cpp isn't run good on gnu/g++, plz help
  2011-06-04  4:49 sine.cpp isn't run good on gnu/g++, plz help eric
@ 2011-06-04  6:14 ` Bryan Hundven
  2011-06-04  6:24   ` Bryan Hundven
  2011-06-04 12:19 ` Jonathan Wakely
  1 sibling, 1 reply; 4+ messages in thread
From: Bryan Hundven @ 2011-06-04  6:14 UTC (permalink / raw)
  To: fsshl; +Cc: oualline, gcc-help

On Fri, Jun 3, 2011 at 9:47 PM, eric <fsshl@att.net> wrote:
> Dear Steve Oualline:
>  the book (Practical C++ Programming), AppendixD
> computing sine using a power series
> the program you listed on page 525, Example D-2 sin/sine.cpp
> I tested on my linux/gnu-g++
> ----------------
> eric@eric-laptop:~/practicalCpp/sin$ ./sine 3.141
> x**1     3.141E+00
> 1!       1.000E+00
> x**1/1! 3.141E+00
>  total   3.141E+00
>
> x**3     3.099E+01
> 3!       6.000E+00
> x**3/3! 5.165E+00
> *** stack smashing detected ***: ./sine terminated
> ======= Backtrace: =========
> /lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x50)[0x3d8390]
> /lib/tls/i686/cmov/libc.so.6(+0xe233a)[0x3d833a]
> ./sine[0x8048e11]
> ./sine[0x8048bb5]
> /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6)[0x30cbd6]
> ./sine[0x80488b1]
> ======= Memory map: ========
> 00110000-00134000 r-xp 00000000 08:01
> 8913271    /lib/tls/i686/cmov/libm-2.11.1.so
> 00134000-00135000 r--p 00023000 08:01
> 8913271    /lib/tls/i686/cmov/libm-2.11.1.so
> 00135000-00136000 rw-p 00024000 08:01
> 8913271    /lib/tls/i686/cmov/libm-2.11.1.so
> 0025b000-00276000 r-xp 00000000 08:01 8913086    /lib/ld-2.11.1.so
> 00276000-00277000 r--p 0001a000 08:01 8913086    /lib/ld-2.11.1.so
> 00277000-00278000 rw-p 0001b000 08:01 8913086    /lib/ld-2.11.1.so
> 002d7000-002f4000 r-xp 00000000 08:01 8912979    /lib/libgcc_s.so.1
> 002f4000-002f5000 r--p 0001c000 08:01 8912979    /lib/libgcc_s.so.1
> 002f5000-002f6000 rw-p 0001d000 08:01 8912979    /lib/libgcc_s.so.1
> 002f6000-00449000 r-xp 00000000 08:01
> 8913215    /lib/tls/i686/cmov/libc-2.11.1.so
> 00449000-0044a000 ---p 00153000 08:01
> 8913215    /lib/tls/i686/cmov/libc-2.11.1.so
> 0044a000-0044c000 r--p 00153000 08:01
> 8913215    /lib/tls/i686/cmov/libc-2.11.1.so
> 0044c000-0044d000 rw-p 00155000 08:01
> 8913215    /lib/tls/i686/cmov/libc-2.11.1.so
> 0044d000-00450000 rw-p 00000000 00:00 0
> 00988000-00989000 r-xp 00000000 00:00 0          [vdso]
> 0099a000-00a83000 r-xp 00000000 08:01 12062387   /usr/lib/libstdc
> ++.so.6.0.13
> 00a83000-00a84000 ---p 000e9000 08:01 12062387   /usr/lib/libstdc
> ++.so.6.0.13
> 00a84000-00a88000 r--p 000e9000 08:01 12062387   /usr/lib/libstdc
> ++.so.6.0.13
> 00a88000-00a89000 rw-p 000ed000 08:01 12062387   /usr/lib/libstdc
> ++.so.6.0.13
> 00a89000-00a90000 rw-p 00000000 00:00 0
> 08048000-0804a000 r-xp 00000000 08:01
> 5507048    /home/eric/practicalCpp/sin/sine
> 0804a000-0804b000 r--p 00001000 08:01
> 5507048    /home/eric/practicalCpp/sin/sine
> 0804b000-0804c000 rw-p 00002000 08:01
> 5507048    /home/eric/practicalCpp/sin/sine
> 08b07000-08b28000 rw-p 00000000 00:00 0          [heap]
> b78bf000-b78c1000 rw-p 00000000 00:00 0
> b78d5000-b78d8000 rw-p 00000000 00:00 0
> bfc8f000-bfca4000 rw-p 00000000 00:00 0          [stack]
> Aborted
> eric@eric-laptop:~/practicalCpp/sin$
> -------------------------------------------
> that certainly is not what your book predict on page 523
> plz help, Eric, US citizen
>
>

Eric,

Some of us don't have the book you reference, but if you post the
code, you might get more help.

-Bryan

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

* Re: sine.cpp isn't run good on gnu/g++, plz help
  2011-06-04  6:14 ` Bryan Hundven
@ 2011-06-04  6:24   ` Bryan Hundven
  0 siblings, 0 replies; 4+ messages in thread
From: Bryan Hundven @ 2011-06-04  6:24 UTC (permalink / raw)
  To: fsshl; +Cc: oualline, gcc-help

On Fri, Jun 3, 2011 at 11:14 PM, Bryan Hundven <bryanhundven@gmail.com> wrote:
> On Fri, Jun 3, 2011 at 9:47 PM, eric <fsshl@att.net> wrote:
>> Dear Steve Oualline:
>>  the book (Practical C++ Programming), AppendixD
>> computing sine using a power series
>> the program you listed on page 525, Example D-2 sin/sine.cpp
>> I tested on my linux/gnu-g++
>> ----------------
>> eric@eric-laptop:~/practicalCpp/sin$ ./sine 3.141
>> x**1     3.141E+00
>> 1!       1.000E+00
>> x**1/1! 3.141E+00
>>  total   3.141E+00
>>
>> x**3     3.099E+01
>> 3!       6.000E+00
>> x**3/3! 5.165E+00
>> *** stack smashing detected ***: ./sine terminated
>> ======= Backtrace: =========
>> /lib/tls/i686/cmov/libc.so.6(__fortify_fail+0x50)[0x3d8390]
>> /lib/tls/i686/cmov/libc.so.6(+0xe233a)[0x3d833a]
>> ./sine[0x8048e11]
>> ./sine[0x8048bb5]
>> /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6)[0x30cbd6]
>> ./sine[0x80488b1]
>> ======= Memory map: ========
>> 00110000-00134000 r-xp 00000000 08:01
>> 8913271    /lib/tls/i686/cmov/libm-2.11.1.so
>> 00134000-00135000 r--p 00023000 08:01
>> 8913271    /lib/tls/i686/cmov/libm-2.11.1.so
>> 00135000-00136000 rw-p 00024000 08:01
>> 8913271    /lib/tls/i686/cmov/libm-2.11.1.so
>> 0025b000-00276000 r-xp 00000000 08:01 8913086    /lib/ld-2.11.1.so
>> 00276000-00277000 r--p 0001a000 08:01 8913086    /lib/ld-2.11.1.so
>> 00277000-00278000 rw-p 0001b000 08:01 8913086    /lib/ld-2.11.1.so
>> 002d7000-002f4000 r-xp 00000000 08:01 8912979    /lib/libgcc_s.so.1
>> 002f4000-002f5000 r--p 0001c000 08:01 8912979    /lib/libgcc_s.so.1
>> 002f5000-002f6000 rw-p 0001d000 08:01 8912979    /lib/libgcc_s.so.1
>> 002f6000-00449000 r-xp 00000000 08:01
>> 8913215    /lib/tls/i686/cmov/libc-2.11.1.so
>> 00449000-0044a000 ---p 00153000 08:01
>> 8913215    /lib/tls/i686/cmov/libc-2.11.1.so
>> 0044a000-0044c000 r--p 00153000 08:01
>> 8913215    /lib/tls/i686/cmov/libc-2.11.1.so
>> 0044c000-0044d000 rw-p 00155000 08:01
>> 8913215    /lib/tls/i686/cmov/libc-2.11.1.so
>> 0044d000-00450000 rw-p 00000000 00:00 0
>> 00988000-00989000 r-xp 00000000 00:00 0          [vdso]
>> 0099a000-00a83000 r-xp 00000000 08:01 12062387   /usr/lib/libstdc
>> ++.so.6.0.13
>> 00a83000-00a84000 ---p 000e9000 08:01 12062387   /usr/lib/libstdc
>> ++.so.6.0.13
>> 00a84000-00a88000 r--p 000e9000 08:01 12062387   /usr/lib/libstdc
>> ++.so.6.0.13
>> 00a88000-00a89000 rw-p 000ed000 08:01 12062387   /usr/lib/libstdc
>> ++.so.6.0.13
>> 00a89000-00a90000 rw-p 00000000 00:00 0
>> 08048000-0804a000 r-xp 00000000 08:01
>> 5507048    /home/eric/practicalCpp/sin/sine
>> 0804a000-0804b000 r--p 00001000 08:01
>> 5507048    /home/eric/practicalCpp/sin/sine
>> 0804b000-0804c000 rw-p 00002000 08:01
>> 5507048    /home/eric/practicalCpp/sin/sine
>> 08b07000-08b28000 rw-p 00000000 00:00 0          [heap]
>> b78bf000-b78c1000 rw-p 00000000 00:00 0
>> b78d5000-b78d8000 rw-p 00000000 00:00 0
>> bfc8f000-bfca4000 rw-p 00000000 00:00 0          [stack]
>> Aborted
>> eric@eric-laptop:~/practicalCpp/sin$
>> -------------------------------------------
>> that certainly is not what your book predict on page 523
>> plz help, Eric, US citizen
>>
>>
>
> Eric,
>
> Some of us don't have the book you reference, but if you post the
> code, you might get more help.
>
> -Bryan
>

Eric,

Actually, sorry. I just found the example code on the o'reilly site.
I compiled and ran it... works for me.

bryan@fling:~/cpp/sin$ uname -a
Linux fling 2.6.38-9-generic #43-Ubuntu SMP Thu Apr 28 15:23:06 UTC
2011 x86_64 x86_64 x86_64 GNU/Linux
bryan@fling:~/cpp/sin$ gcc --version
gcc (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

bryan@fling:~/cpp/sin$ make -f makefile.gnu
g++ -g -Wall -o sine sine.cpp -lm
bryan@fling:~/cpp/sin$ ./sine 3.141
x**1     3.141E+00
1!       1.000E+00
x**1/1! 3.141E+00
  total   3.141E+00

x**3     3.099E+01
3!       6.000E+00
x**3/3! 5.165E+00
  total   -2.024E+00

x**5     3.057E+02
5!       1.200E+02
x**5/5! 2.548E+00
  total   5.239E-01

x**7     3.016E+03
7!       5.040E+03
x**7/7! 5.985E-01
  total   -7.457E-02

x**9     2.976E+04
9!       3.629E+05
x**9/9! 8.201E-02
  total   7.438E-03

x**11     2.936E+05
11!       3.992E+07
x**11/11! 7.355E-03
  total   8.300E-05

x**13     2.897E+06
13!       6.227E+09
x**13/13! 4.652E-04
  total   5.482E-04

x**15     2.858E+07
15!       1.308E+12
x**15/15! 2.185E-05
  total   5.263E-04

x**17     2.819E+08
17!       3.557E+14
x**17/17! 7.927E-07
  total   5.271E-04

x**19     2.782E+09
19!       1.217E+17
x**19/19! 2.287E-08
  total   5.271E-04

x**21     2.744E+10
21!       5.109E+19
x**21/21! 5.371E-10
11 term computed
sin(3.141E+00)=
  5.271E-04
Actual sin(3.141)=0.000592654
bryan@fling:~/cpp/sin$

Maybe take a look at the makefile.gnu from the examples:
http://examples.oreilly.com/9780596004194/

-Bryan

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

* Re: sine.cpp isn't run good on gnu/g++, plz help
  2011-06-04  4:49 sine.cpp isn't run good on gnu/g++, plz help eric
  2011-06-04  6:14 ` Bryan Hundven
@ 2011-06-04 12:19 ` Jonathan Wakely
  1 sibling, 0 replies; 4+ messages in thread
From: Jonathan Wakely @ 2011-06-04 12:19 UTC (permalink / raw)
  To: fsshl; +Cc: gcc-help

On 4 June 2011 05:47, eric <fsshl@att.net> wrote:
> Dear Steve Oualline:

Why are you sending this to gcc-help?  This mailing list is for
questions about using GCC, not for help learning C++ or help copying
an example program from a book correctly.

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

end of thread, other threads:[~2011-06-04 12:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-04  4:49 sine.cpp isn't run good on gnu/g++, plz help eric
2011-06-04  6:14 ` Bryan Hundven
2011-06-04  6:24   ` Bryan Hundven
2011-06-04 12:19 ` Jonathan Wakely

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).