Like Tree1Likes

This compiles!..but segfaults. (Defining main as a functor)

This is a discussion on This compiles!..but segfaults. (Defining main as a functor) within the C++ Programming forums, part of the General Programming Boards category; What was the point of the discussion again?...

  1. #31
    Cat without Hat CornedBee's Avatar
    Join Date
    Apr 2003
    Posts
    8,892
    What was the point of the discussion again?
    All the buzzt!
    CornedBee

    "There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
    - Flon's Law

  2. #32
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,490
    Quote Originally Posted by CornedBee View Post
    What was the point of the discussion again?
    ...whether you're required to jump off a cliff that the standard provides.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  3. #33
    Registered User
    Join Date
    Oct 2006
    Posts
    2,142
    Quote Originally Posted by brewbuck View Post
    On Linux, no way. The data segment most certainly should not be executable. And by "segment" I mean a region of pages defined in the ELF header to be data, and not executable. Not segment in the sense of an x86 segment register, which neither Windows nor Linux make much use of.
    but non-executable (NX bit of the page table entry) pages are only available on 64-bit x86 architectures, so the hardware-level mechanism to prevent data execution on 32-bit x86 processors is much more limited.

  4. #34
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,169
    Windows certainly supports non-executable pages, and there is no indication that it is only available on x64, so it is feasible.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  5. #35
    Registered User
    Join Date
    Oct 2006
    Posts
    2,142
    it's certainly feasible, but from what I can tell, hardware-level data execution prevention is far more limited on 32-bit processors, whereas it's as simple as setting the top bit of a page table entry on the 64-bit processors.

Page 3 of 3 FirstFirst 123
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help with a functor
    By nullspace in forum C++ Programming
    Replies: 1
    Last Post: 08-25-2011, 11:12 PM
  2. Defining functions below int main() - Best practices?
    By Programmer_P in forum C++ Programming
    Replies: 17
    Last Post: 12-09-2009, 01:08 PM
  3. Defining functions outside main - problem
    By helpmeout in forum C++ Programming
    Replies: 16
    Last Post: 03-22-2006, 01:06 AM
  4. Defining main function!
    By alvifarooq in forum C++ Programming
    Replies: 8
    Last Post: 09-19-2004, 02:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21