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

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

    "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
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    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.

  3. #33
    Registered User
    Join Date
    Oct 2006
    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
    Join Date
    Oct 2007
    Inside my computer
    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.

  5. #35
    Registered User
    Join Date
    Oct 2006
    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.

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, 02:08 PM
  3. Defining functions outside main - problem
    By helpmeout in forum C++ Programming
    Replies: 16
    Last Post: 03-22-2006, 02:06 AM
  4. Defining main function!
    By alvifarooq in forum C++ Programming
    Replies: 8
    Last Post: 09-19-2004, 02:00 PM